0

I am trying to pass two parameters through the url in django (email,name) it works fine when I am just passing the email through but when I pass the name through as well I get an error (no reverse match) my name contains a space

url pattern

url(r'^details/(?P<email>[\w.%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4})/(?P<name>([\W ]+))/$', details, name="details")

full error message

Reverse for 'password' with arguments '(u'tom@example.com', u'tom')' and keyword arguments '{}' not found. 1 pattern(s) tried: ['details/(?P<email>[\\w.%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4})/(?P<name>([\\W ]+))/$

passing variable through to the url

{%url 'details' email name %}
Percy3872
  • 17
  • 7

2 Answers2

0

What is the exact error you are getting. When working with multiple variable you can try the following.

{%url 'details' email=email name=name %}

Update:

url(r'^details/(?P<email>[\w.%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4})/(?P<name>([\W ]+))/$', details, name="details")
Bipul Jain
  • 4,523
  • 3
  • 23
  • 26
0

You probably want to change

(?P<name>(\W+))  # non-alphanumeric

to

(?P<name>\w+)  # alphanumeric

The upper-case version is, one would assume, the exact opposite of what you want to allow for names (and urls in general).

Python regex syntax docs.

user2390182
  • 72,016
  • 6
  • 67
  • 89