EN VI

How to fix Django regualr expression Problem?

2024-03-15 18:00:06
How to fix Django regualr expression Problem

Django Rest Framework after User registration sends out an Email for the new User to verify the EMail adress. The link attached is like

https://my_domain.com/api/verify_email/?token=ddfddjrf....fddkfjdjh

my api.urls.py file looks like:

api.urls.py
from django.urls import re_path
from . import views

urlpatterns = [
   re_path(r'^verify_email/(?P<token>[\w.-]+)/',views.verify_email, name="verify_email"),
[

and in project urls.py

...
path('api/', include("api.urls")),
...

When I try to run that link I get:

Page not found (404) The current path api/verify_email/, didn't match any of these.

I can see a URL pattern from the URL.conf: Django tried these URL patterns,in this order.

...

api/ ^verify_email/(?P[\w.-]+)/ [name='verify_email']

...

I hope somebody can help because I can't find a solution somewhere .... And I tried several things to fix it. But without any success. Thank's a lot.

Greetings RR

Solution:

As the error says, it is lacking the token, so you visit it with:

/api/verify_email/ddfddjrf....fddkfjdjh/

not as part of the querystring.

Answer

Login


Forgot Your Password?

Create Account


Lost your password? Please enter your email address. You will receive a link to create a new password.

Reset Password

Back to login