mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Add Whoosh index
This commit is contained in:
@ -190,7 +190,7 @@ class User(AbstractBaseUser):
|
||||
return reverse('core:user_profile', kwargs={'user_id': self.pk})
|
||||
|
||||
def __str__(self):
|
||||
return self.username
|
||||
return self.get_display_name()
|
||||
|
||||
def to_dict(self):
|
||||
return self.__dict__
|
||||
|
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
|
3
core/templates/search/indexes/core/user_text.txt
Normal file
3
core/templates/search/indexes/core/user_text.txt
Normal file
@ -0,0 +1,3 @@
|
||||
{{ object.get_display_name|safe }}
|
||||
{{ object.get_display_name|safe|slugify }}
|
||||
{{ object.get_display_name|safe|slugify|cut:"-" }}
|
Reference in New Issue
Block a user