From 9e1bd2d601ab540eb0d2d383ddeec369ef7c94c1 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Tue, 24 Jun 2014 14:27:40 +0100 Subject: [PATCH] Added get_indexed_objects method to Indexed class This gives developers control over the QuerySet used when the model is added to the indexed --- wagtail/wagtailsearch/indexed.py | 4 ++++ wagtail/wagtailsearch/management/commands/update_index.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wagtail/wagtailsearch/indexed.py b/wagtail/wagtailsearch/indexed.py index a2cb54d14..2e506d690 100644 --- a/wagtail/wagtailsearch/indexed.py +++ b/wagtail/wagtailsearch/indexed.py @@ -118,6 +118,10 @@ class Indexed(object): def get_filterable_search_fields(cls): return filter(lambda field: isinstance(field, FilterField), cls.get_search_fields()) + @classmethod + def get_indexed_objects(cls): + return cls.objects.all() + indexed_fields = () diff --git a/wagtail/wagtailsearch/management/commands/update_index.py b/wagtail/wagtailsearch/management/commands/update_index.py index 2c1593635..c52b75639 100644 --- a/wagtail/wagtailsearch/management/commands/update_index.py +++ b/wagtail/wagtailsearch/management/commands/update_index.py @@ -24,7 +24,7 @@ class Command(BaseCommand): toplevel_content_type = model.indexed_get_toplevel_content_type() # Loop through objects - for obj in model.objects.all(): + for obj in model.get_indexed_objects(): # Get key for this object key = toplevel_content_type + ':' + str(obj.pk)