changeset 678:38a198ea8c61

For issue #49, order search results by newest first.
author Brian Neal <bgneal@gmail.com>
date Wed, 14 Aug 2013 14:53:21 -0500
parents 858ce870c854
children 89b240fe9297
files sg101/urls.py
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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'),
 )