Gabo Lato Gabo Lato - 1 year ago 155
Python Question

Which is the django url regex for a token as a parameter?

I want to activate my users in my django server when they follow a link from their email with a token, like this:

I have this pattern

url(r'^user-activation/(?P<id>\w+)/', views.UserActivation.as_view()),

But it's returning 404. I searched a lot and nothing seems to work. What am I doing wrong?

I couldn't find any answer that works reading



I've read the post

Learning Regular Expressions

But there was no example about receiving hyphens and dots at the same time, which was what caused my confusion.

The marked answer solved my problem. Thanks

Answer Source

Your token also includes . and - characters so you need your regex to match them also - it currently will only match word characters

url(r'^user-activation/(?P<id>[\w\.-]+)/', views.UserActivation.as_view()),
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download