django - How to show haystack query in a different page? -
i've read getting started haystack documentation i'm struggling in how pass queryset results separate page. i've several days trying without results.
i've created own view , form search. called them in search.html template , working ok if show results in there. but, don't how pass results results.html template.
could me define how receive parameters in results view. i'll appreciate much.
views.py
class institutionsearchview(searchview): __name__ = 'institutionsearchview' template = 'search/search.html' def __init__(self, *args, **kwargs): # needed switch out default form class. if kwargs.get('form_class') none: kwargs['form_class'] = institutionsearchform super(institutionsearchview, self).__init__(*args, **kwargs) def search(request): sqs = searchqueryset().facet('type_institution').facet('levels').facet('languages').facet('location') form = institutionsearchform(request.get) if form.is_valid(): cd = form.cleaned_data return institutionsearchview(form_class=institutionsearchform, searchqueryset=sqs)(request) def results(request, *args, **kwargs): return render_to_response('search/results.html', locals(), context_instance=requestcontext(request))
urls.py
urlpatterns = patterns('', url(r'^$', views.search, name='haystack_search'), url(r'^results', views.results, name='results'),)
search.html
<div class="span12"> <h1>search</h1> <form method="get" action="{% url 'institution:results' %}" class=".form-search"> <table> {{ form.as_table }} </table> <input type="submit" value="search"> </form>
results.html
{% if query %} results {% endif %}
Comments
Post a Comment