Commits

Stefan Scherfke committed 09f88f2

Moved search url to weblog’s urlconf.

Comments (0)

Files changed (2)

weblog/search_indexes.py

 # encoding: utf-8
+"""
+Search indexes for Haystack.
+
+"""
 from haystack import indexes, site
 
 from weblog.models import Post
 
 
 class PostIndex(indexes.RealTimeSearchIndex):
+    """
+    Index for :class:`~weblog.models.Post`.
+
+    """
     text = indexes.CharField(document=True, use_template=True)
     title = indexes.CharField(model_attr='title')
     pub_date = indexes.DateTimeField(model_attr='pub_date')
 # encoding: utf-8
 from django.conf.urls.defaults import patterns, url
 from django.views.generic import date_based, list_detail
+from haystack.forms import SearchForm
+from haystack.query import SearchQuerySet
+from haystack.views import SearchView
 
 from weblog.models import Category, Post
 
     'template_object_name': 'category',
 }
 
+sqs = SearchQuerySet().models(Post)
+
 
 urlpatterns = patterns('weblog.views',
     url(r'^$',
     url(r'^category/(?P<path>(([\w-]+)/)+)$',
             'category_detail',
             name='weblog_category_detail'),
+
+    url(r'^search/', SearchView(
+            template='weblog/search.html',
+            searchqueryset=sqs,
+            form_class=SearchForm,
+        ), name='haystack_search'),
 )