0

我对 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 的方法(这意味着查询)。

4

0 回答 0