|
|
|
|
@ -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'))
|
|
|
|
|
),
|
|
|
|
|
]
|