2 from django.conf import settings
3 from haystack import indexes
4 from fnpdjango.utils.models.translation import add_translatable_index, localize_field
5 from events.models import Event
8 class EventIndex(indexes.RealTimeSearchIndex, indexes.Indexable):
9 text = indexes.CharField(null=True,
10 model_attr=localize_field('title', settings.LANGUAGE_CODE),
16 def index_queryset(self):
17 """Used when the entire index for model is updated."""
18 return self.get_model().objects.all()
21 add_translatable_index(EventIndex, {
22 'organizer': indexes.CharField(null=True),
23 'place': indexes.CharField(null=True)
26 add_translatable_index(EventIndex, {
27 'title': indexes.CharField(null=True),
29 (lang for lang in settings.LANGUAGES if lang[0] != settings.LANGUAGE_CODE)