You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DjangoBlog/src/DjangoBlog/accounts/urls.py

60 lines
2.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"""
用户账户应用URL配置模块
本模块定义用户账户相关的所有URL路由包括登录、注册、登出、
密码重置等用户认证相关的端点。
URL模式使用正则表达式和路径转换器来匹配不同的用户操作请求。
"""
from django.urls import path
from django.urls import re_path
# 导入视图模块
from . import views
# 导入自定义登录表单
from .forms import LoginForm
# 应用命名空间用于URL反向解析
app_name = "accounts"
# URL模式列表定义请求URL与视图的映射关系
urlpatterns = [
# 用户登录URL
re_path(r'^login/$', # 匹配 /login/ 路径
# 使用类视图设置登录成功后的重定向URL为首页
views.LoginView.as_view(success_url='/'),
name='login', # URL名称用于反向解析
# 传递额外参数,指定使用自定义登录表单
kwargs={'authentication_form': LoginForm}),
# 用户注册URL
re_path(r'^register/$', # 匹配 /register/ 路径
# 使用类视图设置注册成功后的重定向URL为首页
views.RegisterView.as_view(success_url="/"),
name='register'), # URL名称用于反向解析
# 用户登出URL
re_path(r'^logout/$', # 匹配 /logout/ 路径
# 使用类视图,处理用户登出逻辑
views.LogoutView.as_view(),
name='logout'), # URL名称用于反向解析
# 账户操作结果页面URL
path(r'account/result.html', # 匹配 /account/result.html 路径
# 使用函数视图,显示账户操作结果(如注册成功、验证结果等)
views.account_result,
name='result'), # URL名称用于反向解析
# 忘记密码页面URL
re_path(r'^forget_password/$', # 匹配 /forget_password/ 路径
# 使用类视图,处理密码重置请求
views.ForgetPasswordView.as_view(),
name='forget_password'), # URL名称用于反向解析
# 忘记密码验证码请求URL
re_path(r'^forget_password_code/$', # 匹配 /forget_password_code/ 路径
# 使用类视图,处理发送密码重置验证码的请求
views.ForgetPasswordEmailCode.as_view(),
name='forget_password_code'), # URL名称用于反向解析
]