Question mark in Django URL Mapping

1,020 views
Skip to first unread message

Chen Xu

unread,
Jan 26, 2012, 9:15:19 PM1/26/12
to django...@googlegroups.com
When I type the following as the normal python function, it returns the correct things:

>>> pattern = re.compile(r'^account_activation\?user_id=(?P<user_id>[0-9]+)&auth_key=(?P<auth_key>[0-9a-zA-Z]+)$')
>>> match = pattern.match("account_activation?user_id=36&auth_key=f9717d96aa4e3452a47955225a60862d07119702")
>>> match.groupdict()

{'auth_key': 'f9717d96aa4e3452a47955225a60862d07119702', 'user_id': '36'}

However, when I do this in the Django URL mapping:

url(r'^account_activation?user_id=(?P<user_id>[0-9]+)&auth_key=(?P<auth_key>[0-9a-zA-Z]+)$',
      'activate_registration'),

It seems like the question mark is causing the url mapping not found issue.


Does anyone know why.



Thanks very much
Best regards



--
⚡ Chen Xu

Jani Tiainen

unread,
Jan 27, 2012, 12:23:21 AM1/27/12
to django...@googlegroups.com

Django URL mapping parses only path part of the url. Query string part
(part after question mark) are not parsed by url parser but passed in
request GET dictionary.

More information in
https://docs.djangoproject.com/en/1.3/topics/http/urls/#what-the-urlconf-searches-against

--

Jani Tiainen

Reply all
Reply to author
Forward
0 new messages