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

20 lines
1023 B

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.

# FRR该模块定义评论应用(comments)的URL路由配置
# 映射评论相关的视图函数/类,实现前端请求与后端处理逻辑的关联。
from django.urls import path # 导入Django的path函数用于定义URL路径
from . import views # 导入当前应用的views模块关联评论处理视图
app_name = "comments" # 定义应用命名空间避免不同应用间URL名称冲突
# FRRURL路由列表每个path对应一个评论相关的请求路径
urlpatterns = [
# FRR评论提交路由用于处理用户提交评论的请求
# 路径包含文章ID(article_id),通过<int:article_id>捕获整数类型的文章ID参数
# 关联视图类CommentPostView的as_view()方法(将类视图转为可调用视图函数)
# 命名为'postcomment',便于在模板中通过{% url 'comments:postcomment' article_id %}反向解析
path(
'article/<int:article_id>/postcomment',
views.CommentPostView.as_view(),
name='postcomment'),
]