# HG changeset patch # User Brian Neal # Date 1376510001 18000 # Node ID 38a198ea8c613b5d96f70d42e37832fac39f398d # Parent 858ce870c854e2c10fbcff9096a9c7982f5f9bf1 For issue #49, order search results by newest first. diff -r 858ce870c854 -r 38a198ea8c61 sg101/urls.py --- a/sg101/urls.py Wed Aug 14 13:56:43 2013 -0500 +++ b/sg101/urls.py Wed Aug 14 14:53:21 2013 -0500 @@ -6,6 +6,7 @@ from django.views.generic import TemplateView from haystack.views import search_view_factory +from haystack.query import SearchQuerySet from news.feeds import LatestNewsFeed from forums.feeds import ForumsFeed @@ -87,13 +88,20 @@ ) # Haystack search views + +sqs = SearchQuerySet().order_by('-pub_date') + urlpatterns += patterns('haystack.views', url(r'^search/$', - search_view_factory(form_class=CustomModelSearchForm, load_all=True), + search_view_factory(form_class=CustomModelSearchForm, + searchqueryset=sqs, + load_all=True), name='haystack_search'), url(r'^search/ajax/$', search_view_factory(template='search/search_ajax.html', - form_class=CustomModelSearchForm, load_all=True), + form_class=CustomModelSearchForm, + searchqueryset=sqs, + load_all=True), name='haystack_search_ajax'), )