Commits

Anonymous committed b4e1ebc

search index added

  • Participants
  • Parent commits 347a80f

Comments (0)

Files changed (1)

djangobb_forum/search_indexes.py

+import datetime
+from haystack.indexes import *
+from haystack import site
+from models import Post
+
+class PostIndex(SearchIndex):
+    text = CharField(document=True, use_template=True)
+    category = CharField(model_attr="topic__forum__category__pk") #an Integer Field threw error, therefore CharField
+    forum = IntegerField(model_attr="topic__forum__pk")
+    user = IntegerField(model_attr="user__pk")
+    updated = DateTimeField(model_attr="updated", null=True)
+    created = DateTimeField(model_attr="created")
+
+    def get_queryset(self):
+        return Post.objects.all()
+        
+site.register(Post, PostIndex)