mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-11 12:29:24 +00:00
Add Whoosh index
This commit is contained in:
19
core/search_indexes.py
Normal file
19
core/search_indexes.py
Normal file
@ -0,0 +1,19 @@
|
||||
from haystack import indexes
|
||||
|
||||
from core.models import User
|
||||
|
||||
|
||||
class UserIndex(indexes.SearchIndex, indexes.Indexable):
|
||||
text = indexes.CharField(document=True, use_template=True)
|
||||
|
||||
def get_model(self):
|
||||
return User
|
||||
|
||||
def index_queryset(self, using=None):
|
||||
"""Used when the entire index for model is updated."""
|
||||
return self.get_model().objects.all()
|
||||
|
||||
def prepare(self, obj):
|
||||
ret = super(UserIndex, self).prepare(obj)
|
||||
print(ret)
|
||||
return ret
|
Reference in New Issue
Block a user