search_indexes.py
24 lines
| 616 B
| text/x-python
|
PythonLexer
/ boards / search_indexes.py
neko259
|
r690 | from haystack import indexes | ||
neko259
|
r692 | from boards.models import Post, Tag | ||
neko259
|
r690 | |||
__author__ = 'neko259' | ||||
class PostIndex(indexes.SearchIndex, indexes.Indexable): | ||||
text = indexes.CharField(document=True, use_template=True) | ||||
def get_model(self): | ||||
return Post | ||||
def index_queryset(self, using=None): | ||||
neko259
|
r692 | return self.get_model().objects.all() | ||
class TagIndex(indexes.SearchIndex, indexes.Indexable): | ||||
text = indexes.CharField(document=True, use_template=True) | ||||
def get_model(self): | ||||
return Tag | ||||
def index_queryset(self, using=None): | ||||
return self.get_model().objects.get_not_empty_tags() | ||||