django reverse error NoReverseMatch
given the following
views.py
return redirect('order-review', order=order.id)
urls.py
url(r'^review/$', 'checkout.views.r开发者_高级运维eview', {'order': '0'}, name="order-review"),
aimed at
views.py
def review(request, order):
is there a really obvious fix? I just can't see what i've got wrong and the django docco is slightly light on examples when passing a variable through.
It doesn't resolve, because your url pattern actually hard-codes the order value (it will always be '0').
You have to provide a way to change the order value from within the URL itself.
To be precise:
urls.py
url(r'^review/$', 'checkout.views.review', {'order':'0'}, name="order-review-default-fallback"),
url(r'^review/(?P<order>[\d]+)/$', 'checkout.views.review', {}, name="order-review"),
should solve your problem.
精彩评论