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.
project/src/django-master/comments/urls.py

46 lines
2.2 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.

<<<<<<< HEAD
# 导入Django的URL路径配置模块
from django.urls import path
# 导入当前应用comments的视图模块views.py用于关联URL和视图逻辑
from . import views
# 定义应用命名空间在模板或反向解析URL时需通过「app_name:URL名称」的格式定位如comments:postcomment
# 作用避免不同应用间URL名称冲突
app_name = "comments"
# URL路由列表配置URL路径与视图的映射关系
urlpatterns = [
# 评论提交URL处理用户对特定文章的评论提交请求
path(
# URL路径规则
# - 'article/':固定路径前缀,标识与文章相关的操作
# - '<<int:article_id>/'动态路径参数接收整数类型的文章ID用于指定评论所属文章
# - 'postcomment':固定路径后缀,标识“提交评论”的操作
'article/<<int:article_id>/postcomment',
# 关联的视图调用views.py中的CommentPostView类视图的as_view()方法(类视图需转为视图函数)
# 该视图负责处理评论提交的业务逻辑(如数据验证、保存评论等)
views.CommentPostView.as_view(),
# URL名称用于反向解析如在模板或代码中通过name='postcomment'生成URL
name='postcomment'
),
]
=======
# jyn: 评论应用comments的URL配置模块定义评论相关接口的路由映射
from django.urls import path # jyn: Django URL路径匹配核心函数用于定义路由规则
from . import views # jyn: 导入当前应用的视图模块,关联路由与视图逻辑
app_name = "comments" # jyn: 路由命名空间,避免不同应用间路由名称冲突
urlpatterns = [
# jyn: 提交评论接口路由接收文章ID参数映射到CommentPostView视图类
path(
'article/<<int:article_id>/postcomment', # jyn: 路由路径,<<int:article_id>接收整数型文章ID参数
views.CommentPostView.as_view(), # jyn: 将请求分发到基于类的视图CommentPostView需调用as_view()转换)
name='postcomment' # jyn: 路由名称用于reverse反向解析URL
),
]
>>>>>>> JYN_branch