django-registration-redux の urls を見てみる
django-registration-redux の urls を見てみる
参考:公式
django-registartion のパッケージを確認してみます。
ls -l /usr/local/lib/python3.7/site-packages/registration/
__init__.py
__pycache__
admin.py
auth_urls.py
backends
forms.py
locale
management
migrations
models.py
signals.py
templates
tests
users.py
utils.py
views.py
「path('accounts/', include('registration.backends.default.urls')),」の先を確認してみます。
どうやらアカウントの登録一連のviewを呼び出している見たいですね。
cat /usr/local/lib/python3.7/site-packages/registration/backends/default/urls.py
"""
URLconf for registration and activation, using django-registration's
default backend.
If the default behavior of these views is acceptable to you, simply
use a line like this in your root URLconf to set up the default URLs
for registration::
(r'^accounts/', include('registration.backends.default.urls')),
This will also automatically set up the views in
``django.contrib.auth`` at sensible default locations.
If you'd like to customize registration behavior, feel free to set up
your own URL patterns for these views instead.
"""
from django.conf import settings
from django.conf.urls import include
from django.urls import path
from django.views.generic.base import TemplateView
from .views import ActivationView
from .views import RegistrationView
from .views import ResendActivationView
urlpatterns = [
path('activate/complete/',
TemplateView.as_view(template_name='registration/activation_complete.html'),
name='registration_activation_complete'),
path('activate/resend/',
ResendActivationView.as_view(),
name='registration_resend_activation'),
# Activation keys get matched by \w+ instead of the more specific
# [a-fA-F0-9]{40} because a bad activation key should still get to the view;
# that way it can return a sensible "invalid key" message instead of a
# confusing 404.
path('activate/<activation_key>/',
ActivationView.as_view(),
name='registration_activate'),
path('register/complete/',
TemplateView.as_view(template_name='registration/registration_complete.html'),
name='registration_complete'),
path('register/closed/',
TemplateView.as_view(template_name='registration/registration_closed.html'),
name='registration_disallowed'),
]
if getattr(settings, 'INCLUDE_REGISTER_URL', True):
urlpatterns += [
path('register/',
RegistrationView.as_view(),
name='registration_register'),
]
if getattr(settings, 'INCLUDE_AUTH_URLS', True):
urlpatterns += [
path('', include('registration.auth_urls')),
]
auth_urls.pyを確認してみます。こちらはログイン、ログアウト、パスワード変更、パスワードリセット等のviewを呼び出しているみたいですね。
cat /usr/local/lib/python3.7/site-packages/registration/auth_urls.py
"""
URL patterns for the views included in ``django.contrib.auth``.
Including these URLs (via the ``include()`` directive) will set up the
following patterns based at whatever URL prefix they are included
under:
* User login at ``login/``.
* User logout at ``logout/``.
* The two-step password change at ``password/change/`` and
``password/change/done/``.
* The four-step password reset at ``password/reset/``,
``password/reset/confirm/``, ``password/reset/complete/`` and
``password/reset/done/``.
The default registration backend already has an ``include()`` for
these URLs, so under the default setup it is not necessary to manually
include these views. Other backends may or may not include them;
consult a specific backend's documentation for details.
"""
from django.contrib.auth import views as auth_views
from django.urls import path
from django.urls import reverse_lazy
urlpatterns = [
path('login/',
auth_views.LoginView.as_view(
template_name='registration/login.html'),
name='auth_login'),
path('logout/',
auth_views.LogoutView.as_view(
template_name='registration/logout.html'),
name='auth_logout'),
path('password/change/',
auth_views.PasswordChangeView.as_view(
success_url=reverse_lazy('auth_password_change_done')),
name='auth_password_change'),
path('password/change/done/',
auth_views.PasswordChangeDoneView.as_view(),
name='auth_password_change_done'),
path('password/reset/',
auth_views.PasswordResetView.as_view(
success_url=reverse_lazy('auth_password_reset_done')),
name='auth_password_reset'),
path('password/reset/complete/',
auth_views.PasswordResetCompleteView.as_view(),
name='auth_password_reset_complete'),
path('password/reset/done/',
auth_views.PasswordResetDoneView.as_view(),
name='auth_password_reset_done'),
path('password/reset/confirm/<uidb64>/<token>/',
auth_views.PasswordResetConfirmView.as_view(
success_url=reverse_lazy('auth_password_reset_complete')),
name='auth_password_reset_confirm'),
]
ディスカッション
コメント一覧
まだ、コメントがありません