添加 urls.py 注释

gst_branch
顾思甜 4 months ago
parent 8083c5db73
commit 57e326cd67

@ -1,11 +1,17 @@
# gst: 导入Django的path函数用于定义URL路由规则
from django.urls import path
# gst: 导入当前应用comments的视图模块关联URL与视图逻辑
from . import views
# gst: 定义应用命名空间避免不同应用间URL名称冲突
app_name = "comments"
# gst: URL路由配置列表映射URL路径到对应的视图处理类
urlpatterns = [
path(
'article/<int:article_id>/postcomment',
views.CommentPostView.as_view(),
name='postcomment'),
]
'article/<int:article_id>/postcomment', # gst: 评论提交URL路径<int:article_id>为文章ID路径参数整数类型
views.CommentPostView.as_view(), # gst: 关联评论提交处理视图(基于类的视图)
name='postcomment' # gst: URL名称用于模板反向解析如reverse('comments:postcomment')
),
]
Loading…
Cancel
Save