From: Radek Czajka Date: Thu, 21 Feb 2013 15:27:23 +0000 (+0100) Subject: search: main field=text X-Git-Tag: 0.3.1 X-Git-Url: https://git.mdrn.pl/django-migdal.git/commitdiff_plain/4215649b2a31947ef75b899553577746280b6e8e?ds=sidebyside;hp=601a3722057e0b0fc325d9e6dd1c41eb0713308f search: main field=text --- diff --git a/migdal/search_indexes.py b/migdal/search_indexes.py index 27169f3..5e3f7d4 100644 --- a/migdal/search_indexes.py +++ b/migdal/search_indexes.py @@ -1,11 +1,14 @@ import datetime from django.conf import settings from haystack import indexes -from fnpdjango.utils.models.translation import add_translatable_index +from fnpdjango.utils.models.translation import add_translatable_index, localize_field from migdal.models import Entry class EntryIndex(indexes.RealTimeSearchIndex, indexes.Indexable): + text = indexes.CharField(null=True, + model_attr=localize_field('body', settings.LANGUAGE_CODE), + document=True) date = indexes.DateTimeField(indexed=True, model_attr="date") author = indexes.CharField(model_attr="author") @@ -14,14 +17,18 @@ 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() # filter(date__lte=datetime.datetime.now()) + return self.get_model().objects.all() add_translatable_index(EntryIndex, { 'title': indexes.CharField(null=True), 'lead': indexes.CharField(null=True), - 'body': indexes.CharField(null=True) }) - -getattr(EntryIndex, "body_%s" % settings.LANGUAGE_CODE).document = True +add_translatable_index(EntryIndex, { + 'title': indexes.CharField(null=True), + 'lead': indexes.CharField(null=True), + 'body': indexes.CharField(null=True) + }, + (lang for lang in settings.LANGUAGES if lang[0] != settings.LANGUAGE_CODE) +) diff --git a/setup.py b/setup.py index 5be455f..346e501 100755 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def whole_trees(package_dir, paths): setup( name='django-migdal', - version='0.3', + version='0.3.1', author='Radek Czajka', author_email='radoslaw.czajka@nowoczesnapolska.org.pl', url = '',