Gabo Lato Gabo Lato - 5 months ago 33
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


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()),