<s> from __future__ import absolute_import , unicode_literals <EOL> from django . db import models <EOL> from taggit . managers import TaggableManager <EOL> from wagtail . wagtailsearch import index <EOL> class SearchTest ( models . Model , index . Indexed ) : <EOL> title = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> content = models . TextField ( ) <EOL> live = models . BooleanField ( default = False ) <EOL> published_date = models . DateField ( null = True ) <EOL> tags = TaggableManager ( ) <EOL> search_fields = [ <EOL> index . SearchField ( '<STR_LIT:title>' , partial_match = True ) , <EOL> index . RelatedFields ( '<STR_LIT>' , [ <EOL> index . SearchField ( '<STR_LIT:name>' , partial_match = True ) , <EOL> index . FilterField ( '<STR_LIT>' ) , <EOL> ] ) , <EOL> index . SearchField ( '<STR_LIT:content>' ) , <EOL> index . SearchField ( '<STR_LIT>' ) , <EOL> index . FilterField ( '<STR_LIT:title>' ) , <EOL> index . FilterField ( '<STR_LIT>' ) , <EOL> index . FilterField ( '<STR_LIT>' ) , <EOL> ] <EOL> def callable_indexed_field ( self ) : <EOL> return "<STR_LIT>" <EOL> @ classmethod <EOL> def get_indexed_objects ( cls ) : <EOL> indexed_objects = super ( SearchTest , cls ) . get_indexed_objects ( ) <EOL> if cls is SearchTest : <EOL> indexed_objects = indexed_objects . exclude ( <EOL> id__in = SearchTestChild . objects . all ( ) . values_list ( '<STR_LIT>' , flat = True ) <EOL> ) <EOL> indexed_objects = indexed_objects . exclude ( title = "<STR_LIT>" ) <EOL> return indexed_objects <EOL> def get_indexed_instance ( self ) : <EOL> child = SearchTestChild . objects . filter ( searchtest_ptr_id = self . id ) . first ( ) <EOL> return child or self <EOL> def __str__ ( self ) : <EOL> return self . title <EOL> class SearchTestChild ( SearchTest ) : <EOL> subtitle = models . CharField ( max_length = <NUM_LIT:255> , null = True , blank = True ) <EOL> extra_content = models . TextField ( ) <EOL> page = models . ForeignKey ( '<STR_LIT>' , null = True , blank = True ) <EOL> search_fields = SearchTest . search_fields + [ <EOL> index . SearchField ( '<STR_LIT>' , partial_match = True ) , <EOL> index . SearchField ( '<STR_LIT>' ) , <EOL> index . RelatedFields ( '<STR_LIT>' , [ <EOL> index . SearchField ( '<STR_LIT:title>' , partial_match = True ) , <EOL> index . SearchField ( '<STR_LIT>' ) , <EOL> index . FilterField ( '<STR_LIT>' ) , <EOL> ] ) , <EOL> ] </s>
