I am writing a view which is accepting a email as parameter passed by url like
url(r'^admin/detail_consultant_service/((?P<consultant_id>\[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}))/$',
'admin_tool.views.consultant_service_detail', name="consultant_service_detail"),
And here is the content of my template
{% for consultant in list_consultants %}
<li>
{{consultant.id}}
<a href="{% url consultant_service_detail consultant.id %}">{{ consultant|disp_info }}</a> <br/>
</li>
{% endfor %}
BUt When I am accessing the url I am getting the error
everse for 'consultant_service_detail' with arguments '(u'[email protected]',)' and keyword arguments '{}' not found.
Please help me out What I am doing wrong in my regex why it is not accepting this mail .Is this the problem or something else ?
You are passing a positional argument instead of a keyword argument. The following should work:
{% url consultant_service_detail consultant_id=consultant.id %}
Also if you are using Django>=1.5 you should use the url
as follows:
{% url 'consultant_service_detail' consultant_id=consultant.id %}
And since that is a new behavior, you can actually (which is recommended) use in in earlier versions of Django (I think >=1.3) by:
{% load url from future %}
{% url 'view_name' ... %}
The regex I think is fine according to here so the problem is most likely with the definition itself. Try this:
url(r'^admin/detail_consultant_service/(?P<consultant_id>[\w.%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4})/$',
'admin_tool.views.consultant_service_detail',
name="consultant_service_detail"),
so a valid url will be similar to:
foo.com/admin/detail_consultant_service/[email protected]/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With