summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--askbot/models/__init__.py5
-rw-r--r--askbot/search/haystack/__init__.py15
2 files changed, 13 insertions, 7 deletions
diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py
index 195aa1ec..1827fa62 100644
--- a/askbot/models/__init__.py
+++ b/askbot/models/__init__.py
@@ -105,8 +105,9 @@ def get_users_by_text_query(search_query, users_query_set = None):
For postgres, search also runs against user group names.
"""
if getattr(django_settings, 'ENABLE_HAYSTACK_SEARCH', False):
- from askbot.search.haystack import AskbotSearchQuerySet
- qs = AskbotSearchQuerySet().filter(content=search_query).models(User).get_django_queryset(User)
+ from askbot.search.haystack.searchquery import AskbotSearchQuerySet
+ qs = AskbotSearchQuerySet().filter(content=search_query)
+ qs = qs.models(User).get_django_queryset(User)
return qs
else:
import askbot
diff --git a/askbot/search/haystack/__init__.py b/askbot/search/haystack/__init__.py
index 481f2d72..05580bc4 100644
--- a/askbot/search/haystack/__init__.py
+++ b/askbot/search/haystack/__init__.py
@@ -41,14 +41,19 @@ class PostIndex(indexes.SearchIndex, indexes.Indexable):
def index_queryset(self, using=None):
ALLOWED_TYPES = ('question', 'answer', 'comment')
+ model_cls = self.get_model()
if getattr(settings, 'ASKBOT_MULTILINGUAL', True):
lang_code = get_language()[:2]
- return self.get_model().objects.filter(language_code__startswith=lang_code,
- deleted=False,
- post_type__in=ALLOWED_TYPES)
+ return model_cls.objects.filter(
+ language_code__startswith=lang_code,
+ deleted=False,
+ post_type__in=ALLOWED_TYPES
+ )
else:
- return self.get_model().objects.filter(deleted=False,
- post_type__in=ALLOWED_TYPES)
+ return model_cls.objects.filter(
+ deleted=False,
+ post_type__in=ALLOWED_TYPES
+ )
class UserIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)