我有Django和Haystack的问题。我正在尝试美化网址(example.com/search/?q=hey in example / search / hey /),如下所示:
def go(request):
"""
Search > Beautify
"""
search_query = request.GET.get('q', None)
return HttpResponseRedirect(reverse('search.views.root', kwargs={
'search_query': search_query,
}))
def root(request, search_query):
"""
Search > Root
"""
form = HaystackSearchForm(request.GET)
tutorials = form.search()
return render(request, 'search/search_root.html', {
'search_query' : search_query,
'tutorials' : tutorials,
})
问题是它不起作用,因为go函数的请求与root函数不同。我想找到一种方法将适当的请求传递给HaystackForm(这与查询有关)。