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 migdal.models import Entry
8 class EntryIndex(indexes.SearchIndex, indexes.Indexable):
9 text = indexes.CharField(null=True,
10 model_attr=localize_field('body', settings.LANGUAGE_CODE),
12 date = indexes.DateTimeField(indexed=True, model_attr="date")
13 author = indexes.CharField(model_attr="author")
18 def index_queryset(self):
19 """Used when the entire index for model is updated."""
20 return self.get_model().objects.all()
23 add_translatable_index(EntryIndex, {
24 'title': indexes.CharField(null=True),
25 'lead': indexes.CharField(null=True),
28 add_translatable_index(EntryIndex, {
29 'title': indexes.CharField(null=True),
30 'lead': indexes.CharField(null=True),
31 'body': indexes.CharField(null=True)
33 (lang for lang in settings.LANGUAGES if lang[0] != settings.LANGUAGE_CODE)