Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django 2.0 custom url regex

Tags:

django

I had a url pattern like

url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', auth_views.PasswordResetConfirmView.as_view(template_name='password_reset_confirm.html'),

how can I use this as new path pattern

like image 378
nikolas Avatar asked Dec 24 '17 18:12

nikolas


2 Answers

In django.contrib.auth.urls the view is included as

path('reset/<uidb64>/<token>/', views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
like image 89
Alasdair Avatar answered Sep 27 '22 18:09

Alasdair


Use re_path instead of url.

from django.url import re_path

re_path(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', auth_views.PasswordResetConfirmView.as_view(template_name='password_reset_confirm.html'),

https://docs.djangoproject.com/en/2.0/ref/urls/

like image 26
Luis Gutierrez Avatar answered Sep 27 '22 18:09

Luis Gutierrez