The title pretty much sums it up – I have this tag in a template:
<a href="{% url mainapp.views.send_registration_email_view user_email=for_user.email,company_number=company.pk,organisation='org' %}">
with this in urls.py:
(r'^send/registrationlink/(?P<user_email>[^/]+)/(?P<company_number>[^/]+)/(?P<organisation>\w+)/?$', 'mainapp.views.send_registration_email_view'),
and this in mainapp/views.py:
def send_registration_email_view(request, user_email = None, company_number = None, organisation = None):
However, attempting to view a page which imports the template in which the problematic line is found, leads to this error:
TemplateSyntaxError: Caught NoReverseMatch while rendering: Reverse for 'mainapp.views.send_registration_email_view' with arguments '()' and keyword arguments '{'organisation': u'org', 'company_number': u'UN58e2391e-51a5-11e1-bb6a-e89a8f7f9c14', 'user_email': ''}' not found.
I also have these tags in the same template, and they work fine:
<a href="{% url mainapp.views.registration_view for_user=for_user %}">
<a href="{% url mainapp.views.consent_view for_user=for_user %}">
So – does anyone know why django doesn’t like what I’m doing?
This part of the regex:
(?P<user_email>[^/]+)expects at least one character, but you’re passing an empty string asuser_email. In a regex,+means ‘one or more’. Change it to*to also accept an empty string.http://docs.python.org/library/re.html#regular-expression-syntax