Hi all,
I am trying to use django-haystack (been around 2 days now), and I
have got the basic Getting Started example working and it looks very
impressive. I would now like to try the autocomplete function on
haystack.
http://readthedocs.org/docs/django-haystack/en/v1.2.4/autocomplete.html
The first part seems fine: "Setting up the data" seems simple enough.
However, I am not sure where the "Performing the Query" needs to be
written: i.e 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 set up 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 the sqs be specified? in the urls.py or views.py? I
tried both, but they give me a name error "request" not found on the
sqs statement.
I have been struck with this problem for about 2 days now, and I would
appreciate any suggestions or directions.
Many thanks.