在重定向到特定 url 时,我试图将变量 ( cat
) 传递给视图。使用reverse
类似:
return HttpResponseRedirect(reverse('show_poll'), args=[cat])
上面的重定向将转到以下视图:
def show_poll(request, cat):
print cat
网址为
url(r'^show/(?P<cat>\w+)/$', 'pollsite.views.show_poll', name="show_poll"),
得到:Reverse for 'show_poll' with arguments '()' and keyword arguments '{}' not found.
我在这里想念什么?