Commit 404b825d authored by Sli's avatar Sli Committed by Skia

forum: make search fuzzy

parent 286ba91c
......@@ -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
{{ 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]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment