Skip to content

Commit

Permalink
Use path instead of re_path in most cases
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemanger committed Jul 29, 2024
1 parent b05899c commit b2a0ff6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 29 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Unreleased

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

0.8.6
-----
Expand Down
6 changes: 3 additions & 3 deletions docs/topics/custom.validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ URL pattern needs to be added to a project's ``URLconf``::

from your_app.forms import CustomPasswordPoliciesForm

urlpatterns = patterns('',
(r'^password/reset/', PasswordResetConfirmView.as_view(form_class=CustomPasswordPoliciesForm)),
)
urlpatterns = [
path("password/reset/", PasswordResetConfirmView.as_view(form_class=CustomPasswordPoliciesForm)),
]
20 changes: 4 additions & 16 deletions password_policies/tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
try:
from django.conf.urls import include, url
except ImportError:
from django.urls import include
from django.urls import re_path as url

try:
from django.conf.urls import patterns
except ImportError:
patterns = False
from django.urls import include, path

from password_policies.tests.views import TestHomeView, TestLoggedOutMixinView

urlpatterns = [
url(r"^password/", include("password_policies.urls")),
url(r"^$", TestHomeView.as_view(), name="home"),
url(r"^fubar/", TestLoggedOutMixinView.as_view(), name="loggedoutmixin"),
path("password/", include("password_policies.urls")),
path("", TestHomeView.as_view(), name="home"),
path("fubar/", TestLoggedOutMixinView.as_view(), name="loggedoutmixin"),
]

if patterns:
urlpatterns = patterns("", *urlpatterns) # noqa
18 changes: 8 additions & 10 deletions password_policies/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.urls import re_path as url
from django.urls import path, re_path

from password_policies.views import (
PasswordChangeDoneView,
Expand All @@ -10,20 +10,18 @@
)

urlpatterns = [
url(
r"^change/done/$", PasswordChangeDoneView.as_view(), name="password_change_done"
),
url(r"^change/$", PasswordChangeFormView.as_view(), name="password_change"),
url(r"^reset/$", PasswordResetFormView.as_view(), name="password_reset"),
url(
r"^reset/complete/$",
path("change/done/", PasswordChangeDoneView.as_view(), name="password_change_done"),
path("change/", PasswordChangeFormView.as_view(), name="password_change"),
path("reset/", PasswordResetFormView.as_view(), name="password_reset"),
path(
"reset/complete/",
PasswordResetCompleteView.as_view(),
name="password_reset_complete",
),
url(
re_path(
r"^reset/confirm/([0-9A-Za-z_\-]+)/([0-9A-Za-z]{1,13})/([0-9A-Za-z-=_]{1,128})/$",
PasswordResetConfirmView.as_view(),
name="password_reset_confirm",
),
url(r"^reset/done/$", PasswordResetDoneView.as_view(), name="password_reset_done"),
path("reset/done/", PasswordResetDoneView.as_view(), name="password_reset_done"),
]

0 comments on commit b2a0ff6

Please sign in to comment.