Thursday, January 26, 2012

Re: Question mark in Django URL Mapping

On 27.1.2012 4:15, Chen Xu wrote:
> 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.

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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate