django pass extra option through url templatetag to view
I have the following line in my url file
url(r'^confirm/$', 'confirm', {'status':'live'}, name="confirm"),
As you can see I am passing the extra option status
to the view which is described here
I would like to pass the status value through the template u开发者_如何学Pythonsing the url
templatetag. I tried
{% url confirm status='pending' %}
but I get the following error:
Caught NoReverseMatch while rendering: Reverse for 'confirm' with arguments '()' and keyword arguments '{'status': u'pending'}' not found. Is it possible to do what I am trying to do?
How could this work? The url
tag just outputs a URL that is valid in your urlconf and which maps the arguments into the URL. But your url has no place for alternative values for status - it's hard-coded.
If you want to pass parameters into a URL pattern, the pattern needs to have a space for the parameter.
精彩评论