shibly shibly - 5 months ago 11
Python Question

How can I set a url that takes one parameter with aphanumeric string?

What I'm trying to do:

url(r'^confirmemail/[a-bA-z0-9]+/', 'blog.views.confirmemail'),


The exact url would be something like that: http://127.0.0.1:8000/confirmemail/tubwp2n0a6 or http://127.0.0.1:8000/confirmemail/tubwp2n0a6/

The length of the string parameter would be ten(10).

How can write that url in urls.py?

Answer

url(r'^confirmemail/(?P<code>[a-zA-Z0-9]+)/', 'blog.views.confirmemail'),

or

url(r'^confirmemail/(?P<code>[a-zA-Z0-9]{10})/', 'blog.views.confirmemail'), to restrict length to the 10 symbols.