From d902ff50c0326143915c3e5deaa7059e6d57f6d4 Mon Sep 17 00:00:00 2001 From: Marcin Koziej Date: Tue, 28 Aug 2012 11:54:27 +0200 Subject: [PATCH 1/1] allow null values on fields --- events/search_indexes.py | 9 ++++----- migdal/search_indexes.py | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/events/search_indexes.py b/events/search_indexes.py index 1321dcd..9977957 100644 --- a/events/search_indexes.py +++ b/events/search_indexes.py @@ -12,16 +12,15 @@ class EventIndex(indexes.RealTimeSearchIndex, indexes.Indexable): def index_queryset(self): """Used when the entire index for model is updated.""" return self.get_model().objects.all() - + add_translatable_index(EventIndex, { # Haystack needs a main field to be the same across all indexes # so we treat title of the event as this main content, named 'body' - 'body': indexes.CharField(model_attr='title'), - 'organizer': indexes.CharField(), - 'place': indexes.CharField() + 'body': indexes.CharField(model_attr='title', null=True), + 'organizer': indexes.CharField(null=True), + 'place': indexes.CharField(null=True) }) getattr(EventIndex, "body_%s" % settings.LANGUAGE_CODE).document = True - diff --git a/migdal/search_indexes.py b/migdal/search_indexes.py index 2001dab..4257483 100644 --- a/migdal/search_indexes.py +++ b/migdal/search_indexes.py @@ -14,13 +14,13 @@ class EntryIndex(indexes.RealTimeSearchIndex, indexes.Indexable): def index_queryset(self): """Used when the entire index for model is updated.""" - return self.get_model().objects.all() # from example: filter(date__lte=datetime.datetime.now()) + return self.get_model().objects.all() # filter(date__lte=datetime.datetime.now()) add_translatable_index(EntryIndex, { - 'title': indexes.CharField(), - 'lead': indexes.CharField(), - 'body': indexes.CharField() + 'title': indexes.CharField(null=True), + 'lead': indexes.CharField(null=True), + 'body': indexes.CharField(null=True) }) -- 2.20.1