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

23 lines
1.1 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路径到对应视图支持通过文章ID关联评论目标
# 赵瑞萍导入Django URL核心函数用于定义路径匹配规则
from django.urls import path
# 赵瑞萍:导入当前应用的视图模块,关联评论提交的处理逻辑
from . import views
# 赵瑞萍:定义应用命名空间"comments"避免多应用间URL名称冲突
# 模板中引用格式:{% url 'comments:postcomment' article_id %}
app_name = "comments"
# 赵瑞萍URL模式列表存储该应用的所有路由规则
urlpatterns = [
# 赵瑞萍:评论提交路由,用于处理用户发布/回复评论的请求
path(
'article/<int:article_id>/postcomment', # URL路径包含整数类型的文章ID参数article_id
# 关联视图类将CommentPostView类视图转换为可调用的视图函数
views.CommentPostView.as_view(),
name='postcomment' # URL名称用于反向解析如reverse('comments:postcomment')
),
]