mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +00:00
forum: make search fuzzy
This commit is contained in:
parent
286ba91c75
commit
404b825de4
@ -59,6 +59,7 @@ class UserOnlySignalProcessor(signals.BaseSignalProcessor):
|
||||
|
||||
class ForumMessageIndex(indexes.SearchIndex, indexes.Indexable):
|
||||
text = indexes.CharField(document=True, use_template=True)
|
||||
auto = indexes.EdgeNgramField(use_template=True)
|
||||
|
||||
def get_model(self):
|
||||
return ForumMessage
|
||||
|
@ -0,0 +1,4 @@
|
||||
{{ object.topic }}
|
||||
{{ object.title }}
|
||||
{{ object.message }}
|
||||
{{ object.author }}
|
@ -47,7 +47,7 @@ class ForumSearchView(ListView):
|
||||
|
||||
def get_queryset(self):
|
||||
query = self.request.GET.get("query", "")
|
||||
q = SearchQuerySet().models(ForumMessage).filter_or(text__contains=query)
|
||||
q = SearchQuerySet().models(ForumMessage).autocomplete(auto=query)
|
||||
return [r.object for r in q]
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user