1 from django.conf import settings
3 from haystack import indexes
4 from events.models import Event
5 from migdal.helpers import add_translatable_index
8 class EventIndex(indexes.RealTimeSearchIndex, indexes.Indexable):
12 def index_queryset(self):
13 """Used when the entire index for model is updated."""
14 return self.get_model().objects.all()
17 add_translatable_index(EventIndex, {
18 # Haystack needs a main field to be the same across all indexes
19 # so we treat title of the event as this main content, named 'body'
20 'body': indexes.CharField(model_attr='title', null=True),
21 'organizer': indexes.CharField(null=True),
22 'place': indexes.CharField(null=True)
26 getattr(EventIndex, "body_%s" % settings.LANGUAGE_CODE).document = True