mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 11:04:20 +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):
|
class ForumMessageIndex(indexes.SearchIndex, indexes.Indexable):
|
||||||
text = indexes.CharField(document=True, use_template=True)
|
text = indexes.CharField(document=True, use_template=True)
|
||||||
|
auto = indexes.EdgeNgramField(use_template=True)
|
||||||
|
|
||||||
def get_model(self):
|
def get_model(self):
|
||||||
return ForumMessage
|
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):
|
def get_queryset(self):
|
||||||
query = self.request.GET.get("query", "")
|
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]
|
return [r.object for r in q]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user