Search results are chronological
Also moved to search_view_factory because apparently it's thread-safe and I think Apache runs multiple threads.
This commit is contained in:
parent
e72d87415c
commit
d81c8cbda1
|
@ -3,6 +3,7 @@ from .models import Thought
|
||||||
|
|
||||||
class ThoughtIndex(indexes.SearchIndex, indexes.Indexable):
|
class ThoughtIndex(indexes.SearchIndex, indexes.Indexable):
|
||||||
text = indexes.CharField(document=True, use_template=True, template_name="search/indexes/main/thought_text.txt")
|
text = indexes.CharField(document=True, use_template=True, template_name="search/indexes/main/thought_text.txt")
|
||||||
|
posted = indexes.DateTimeField(model_attr="posted")
|
||||||
|
|
||||||
def get_model(self):
|
def get_model(self):
|
||||||
return Thought
|
return Thought
|
||||||
|
|
|
@ -5,7 +5,8 @@ from main import views
|
||||||
from main.feed import MainFeed
|
from main.feed import MainFeed
|
||||||
from whispermaphone import settings
|
from whispermaphone import settings
|
||||||
|
|
||||||
from haystack.views import SearchView
|
from haystack.views import SearchView, search_view_factory
|
||||||
|
from haystack.query import SearchQuerySet
|
||||||
from haystack.forms import SearchForm
|
from haystack.forms import SearchForm
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
@ -14,5 +15,9 @@ urlpatterns = [
|
||||||
path("login", views.login, name="login"),
|
path("login", views.login, name="login"),
|
||||||
path("post", views.post, name="post"),
|
path("post", views.post, name="post"),
|
||||||
path("feed", MainFeed()),
|
path("feed", MainFeed()),
|
||||||
path("search", SearchView(form_class=SearchForm), name="thoughts_search")
|
path("search", search_view_factory(
|
||||||
|
view_class=SearchView,
|
||||||
|
form_class=SearchForm,
|
||||||
|
searchqueryset=SearchQuerySet().order_by("-posted")
|
||||||
|
), name="thoughts_search")
|
||||||
] + (static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) if settings.DEBUG else [])
|
] + (static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) if settings.DEBUG else [])
|
||||||
|
|
Loading…
Reference in New Issue