コード例 #1
0
class BlogIndex(indexes.SearchIndex):
    model = Blog

    created = indexes.ModelField(model_field='created')
    updated = indexes.ModelField(model_field='updated')
    author = indexes.ModelField(model_field='author')
    authors_name = indexes.TemplateField()
    title = indexes.ModelField(model_field='title')
    document = indexes.TemplateField(model_field='filtered_description')

    def get_index_queryset(self, using=None):
        return (self.get_model().objects.prefetch_related(
            indexes.AuthorPrefetch()).using(using))
コード例 #2
0
class DesktopIndex(indexes.SearchIndex):
    model = Desktop

    created = indexes.ModelField(model_field='created')
    updated = indexes.ModelField(model_field='updated')
    author = indexes.ModelField(model_field='author')
    authors_name = indexes.TemplateField()
    title = indexes.ModelField(model_field='title')
    document = indexes.TemplateField(model_field='filtered_text')
    comments = indexes.CommentsField()

    def get_index_queryset(self, using=None):
        return (self.get_model().objects.using(using).prefetch_related(
            indexes.CommentsPrefetch(), indexes.AuthorPrefetch()))
コード例 #3
0
class PostIndex(indexes.SearchIndex):
    model = Post

    created = indexes.ModelField(model_field='created')
    updated = indexes.ModelField(model_field='updated')
    author = indexes.ModelField(model_field='blog__author')
    authors_name = indexes.TemplateField()
    title = indexes.ModelField(model_field='title')
    document = indexes.TemplateField(model_field='filtered_content')
    comments = indexes.CommentsField()

    def get_index_queryset(self, using=None):
        return (self.get_model().objects.prefetch_related(
            indexes.CommentsPrefetch(), 'blog',
            indexes.AuthorPrefetch('blog__author')).using(using).published())
コード例 #4
0
class NodeIndex(indexes.SearchIndex):
	model = Node

	created = indexes.ModelField(model_field='created')
	updated = indexes.ModelField(model_field='updated')
	title = indexes.ModelField(model_field='title')
	document = indexes.TemplateField(model_field='text')

	def get_index_queryset(self, using=None):
		return self.get_model().objects.using(using).filter(node_type='story').select_related('revision')
コード例 #5
0
class ArticleIndex(indexes.SearchIndex):
    model = Article

    created = indexes.ModelField(model_field='pub_time')
    updated = indexes.ModelField(model_field='updated')
    author = indexes.ModelField(model_field='author')
    authors_name = indexes.ModelField(model_field='authors_name')
    title = indexes.ModelField(model_field='title')
    document = indexes.TemplateField(model_field='filtered_content')
    comments = indexes.CommentsField()

    def get_index_queryset(self, using=None):
        return (self.get_model().objects.using(using).prefetch_related(
            indexes.CommentsPrefetch(),
            indexes.AuthorPrefetch()).filter(pub_time__lte=timezone.now(),
                                             published=True))