Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

search index for haystack 2.0

  • Loading branch information...
commit fdb5b22d1895a9919b67a05072320521df528918 1 parent 6dbc14b
@philippWassibauer philippWassibauer authored
Showing with 7 additions and 24 deletions.
  1. +7 −24 threaded_messages/search_indexes.py
View
31 threaded_messages/search_indexes.py
@@ -1,11 +1,10 @@
-from haystack.indexes import *
-from haystack import site
+from haystack import indexes
from models import Thread
-class ThreadIndex(RealTimeSearchIndex):
- text = CharField(document=True, use_template=True)
- participants = MultiValueField()
- last_message = DateTimeField(model_attr='latest_msg__sent_at')
+class ThreadIndex(indexes.SearchIndex, indexes.Indexable):
+ text = indexes.CharField(document=True, use_template=True)
+ participants = indexes.MultiValueField()
+ last_message = indexes.DateTimeField(model_attr='latest_msg__sent_at')
def index_queryset(self):
return Thread.objects.all()
@@ -13,23 +12,7 @@ def index_queryset(self):
def prepare_participants(self, object):
return [p.user.pk for p in object.participants.all()]
-site.register(Thread, ThreadIndex)
+ def get_model(self):
+ return Thread
-#from haystack import indexes
-#from models import Thread
-#
-#class ThreadIndex(indexes.SearchIndex, indexes.Indexable):
-# text = indexes.CharField(document=True, use_template=True)
-# participants = indexes.MultiValueField()
-# last_message = indexes.DateTimeField(model_attr='latest_msg__sent_at')
-#
-# def index_queryset(self):
-# return Thread.objects.all()
-#
-# def prepare_participants(self, object):
-# return [p.user.pk for p in object.participants.all()]
-#
-# def get_model(self):
-# return Thread
-#
Please sign in to comment.
Something went wrong with that request. Please try again.