Skip to content

Commit b2a0ff6

Browse files
committed
Use path instead of re_path in most cases
1 parent b05899c commit b2a0ff6

File tree

4 files changed

+16
-29
lines changed

4 files changed

+16
-29
lines changed

HISTORY.rst

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Unreleased
33

44
* Remove unsupported Django code
55
* Added ``__str__()`` definitions for models
6+
* Use path instead of re_path for some URLs
67

78
0.8.6
89
-----

docs/topics/custom.validation.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ URL pattern needs to be added to a project's ``URLconf``::
6868

6969
from your_app.forms import CustomPasswordPoliciesForm
7070

71-
urlpatterns = patterns('',
72-
(r'^password/reset/', PasswordResetConfirmView.as_view(form_class=CustomPasswordPoliciesForm)),
73-
)
71+
urlpatterns = [
72+
path("password/reset/", PasswordResetConfirmView.as_view(form_class=CustomPasswordPoliciesForm)),
73+
]

password_policies/tests/urls.py

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
try:
2-
from django.conf.urls import include, url
3-
except ImportError:
4-
from django.urls import include
5-
from django.urls import re_path as url
6-
7-
try:
8-
from django.conf.urls import patterns
9-
except ImportError:
10-
patterns = False
1+
from django.urls import include, path
112

123
from password_policies.tests.views import TestHomeView, TestLoggedOutMixinView
134

145
urlpatterns = [
15-
url(r"^password/", include("password_policies.urls")),
16-
url(r"^$", TestHomeView.as_view(), name="home"),
17-
url(r"^fubar/", TestLoggedOutMixinView.as_view(), name="loggedoutmixin"),
6+
path("password/", include("password_policies.urls")),
7+
path("", TestHomeView.as_view(), name="home"),
8+
path("fubar/", TestLoggedOutMixinView.as_view(), name="loggedoutmixin"),
189
]
19-
20-
if patterns:
21-
urlpatterns = patterns("", *urlpatterns) # noqa

password_policies/urls.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django.urls import re_path as url
1+
from django.urls import path, re_path
22

33
from password_policies.views import (
44
PasswordChangeDoneView,
@@ -10,20 +10,18 @@
1010
)
1111

1212
urlpatterns = [
13-
url(
14-
r"^change/done/$", PasswordChangeDoneView.as_view(), name="password_change_done"
15-
),
16-
url(r"^change/$", PasswordChangeFormView.as_view(), name="password_change"),
17-
url(r"^reset/$", PasswordResetFormView.as_view(), name="password_reset"),
18-
url(
19-
r"^reset/complete/$",
13+
path("change/done/", PasswordChangeDoneView.as_view(), name="password_change_done"),
14+
path("change/", PasswordChangeFormView.as_view(), name="password_change"),
15+
path("reset/", PasswordResetFormView.as_view(), name="password_reset"),
16+
path(
17+
"reset/complete/",
2018
PasswordResetCompleteView.as_view(),
2119
name="password_reset_complete",
2220
),
23-
url(
21+
re_path(
2422
r"^reset/confirm/([0-9A-Za-z_\-]+)/([0-9A-Za-z]{1,13})/([0-9A-Za-z-=_]{1,128})/$",
2523
PasswordResetConfirmView.as_view(),
2624
name="password_reset_confirm",
2725
),
28-
url(r"^reset/done/$", PasswordResetDoneView.as_view(), name="password_reset_done"),
26+
path("reset/done/", PasswordResetDoneView.as_view(), name="password_reset_done"),
2927
]

0 commit comments

Comments
 (0)