I am trying to use django-haystack (it was about 2 days) and I have a basic Getting Started example and it looks very impressive. Now I would like to try the autocomplete function on a haystack.
http://readthedocs.org/docs/django-haystack/en/v1.2.4/autocomplete.html
The first part seems beautiful: "Setting up the data" seems quite simple. However, I'm not sure where to write "Executing the request": ie in which view should I include:
from haystack.query import SearchQuerySet sqs = SearchQuerySet().filter(content_auto=request.GET.get('q', ''))
My current urls.py is simple and configured as follows:
urlpatterns = patterns('', # Examples: ('^hello/$', hello), (r'^$', hello), (r'^search/', include('haystack.urls')), # url(r'^$', 'mysite.views.home', name='home'), # url(r'^mysite/', include('mysite.foo.urls')), # Uncomment the admin/doc line below to enable admin documentation: #url(r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: url(r'^admin/', include(admin.site.urls)), )
Looking at the following blog:
http://tech.agilitynerd.com/haystack-search-result-ordering-and-pre-rende
I would like to have something like:
url(r'^search/', SearchView(load_all=False,searchqueryset=sqs),name='haystack_search'),
but where should sqs be specified? in urls.py or views.py? I tried both, but they give me a "query" error, which is not found in the sqs statement.