0

在重定向到特定 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.

我在这里想念什么?

4

1 回答 1

1

传递argsreverse()as

return HttpResponseRedirect(reverse('show_poll', args=[cat]))
#-----------------------------------------------^ closing bracket moved at the end
于 2013-09-26T07:13:11.140 回答