2 from django.conf import settings
3 from haystack import indexes
4 from fnpdjango.utils.models.translation import add_translatable_index
5 from migdal.models import Entry
8 class EntryIndex(indexes.RealTimeSearchIndex, indexes.Indexable):
9 date = indexes.DateTimeField(indexed=True, model_attr="date")
10 author = indexes.CharField(model_attr="author")
15 def index_queryset(self):
16 """Used when the entire index for model is updated."""
17 return self.get_model().objects.all() # filter(date__lte=datetime.datetime.now())
20 add_translatable_index(EntryIndex, {
21 'title': indexes.CharField(null=True),
22 'lead': indexes.CharField(null=True),
23 'body': indexes.CharField(null=True)
27 getattr(EntryIndex, "body_%s" % settings.LANGUAGE_CODE).document = True