Cannot resolve Django "NoReverseMatch" exception with kwargs
I have am unable to get Django to reverse-resolve the following named url -
URLconf ent开发者_JS百科ry :
url(r'^shotmanager/(?P<shotid>\d+)/$', 'ctac.views.shotManager', {'message': "", 'errors': []}, name = 'shot-manager')
HttpResponseRedirect call:
return HttpResponseRedirect(reverse("shot-manager", kwargs={'shotid': id, 'message': s, 'errors': errorList}))
I see nothing in the Django docs that suggests I cannot mix kwargs in the url and the dictionary entry in the url. For some reason, reverse will resolve fine if I only send it "shotid".
I have already visited the following thread
Reversing Django URLs With Extra Options
and have studied it. It is unclear if it was resolved either.
reverse
returns a URL populated with the values you pass in the args or kwargs. But the URL you are trying to generate hasn't got a space for message
. Where would it go in the generated URL?
Edit in response to comment If you want to pass messages between page views, the correct way to do it is not via the URL, but by via the session. Django even includes a messaging framework to manage this for you.
精彩评论