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.
Django/urls.py

53 lines
2.0 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路径函数
from django.urls import path
# 导入正则URL路径函数兼容老版本
from django.urls import re_path
# 导入当前应用的视图
from . import views
# 导入登录表单
from .forms import LoginForm
# 应用命名空间用于URL反向解析
app_name = "accounts"
# URL模式列表
urlpatterns = [
# 登录URL - 使用正则表达式匹配 /login/ 路径
re_path(r'^login/$',
# 使用LoginView视图类登录成功后重定向到首页
views.LoginView.as_view(success_url='/'),
name='login', # URL名称login
# 传入额外参数:指定认证表单类
kwargs={'authentication_form': LoginForm}),
# 注册URL - 使用正则表达式匹配 /register/ 路径
re_path(r'^register/$',
# 使用RegisterView视图类注册成功后重定向到首页
views.RegisterView.as_view(success_url="/"),
name='register'), # URL名称register
# 登出URL - 使用正则表达式匹配 /logout/ 路径
re_path(r'^logout/$',
# 使用LogoutView视图类
views.LogoutView.as_view(),
name='logout'), # URL名称logout
# 账户结果页面URL - 使用path匹配固定路径
path(r'account/result.html',
# 使用account_result函数视图
views.account_result,
name='result'), # URL名称result
# 忘记密码URL - 使用正则表达式匹配 /forget_password/ 路径
re_path(r'^forget_password/$',
# 使用ForgetPasswordView视图类
views.ForgetPasswordView.as_view(),
name='forget_password'), # URL名称forget_password
# 获取忘记密码验证码URL - 使用正则表达式匹配 /forget_password_code/ 路径
re_path(r'^forget_password_code/$',
# 使用ForgetPasswordEmailCode视图类
views.ForgetPasswordEmailCode.as_view(),
name='forget_password_code'), # URL名称forget_password_code
]