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.
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.
# zy:comments/urls.py
# zy:评论(Comment)应用的URL路由配置文件
# zy:该文件定义了评论功能的所有URL模式和对应的视图处理
#zy: 导入Django的URL路由配置模块, path函数用于定义URL模式
from django . urls import path
#zy: 从当前包(views模块)导入所有视图函数或类
from . import views
# zy:定义应用的命名空间, 用于URL反向解析时区分不同应用的相同名称URL
#zy: 当在模板中使用{% url 'comments:add_comment' post_id=1 %}时会指向此应用的add_comment URL
app_name = ' comments '
# zy:定义URL模式列表, Django会按顺序匹配这些模式
# zy:每个path()函数定义一个URL模式及其对应的视图
urlpatterns = [
# zy:定义添加评论的URL模式
path (
# URL路径模式, 使用尖括号定义路径参数:
# - 'post/' 固定文本部分
# - '<int:post_id>' 路径转换器, 匹配整数并将其作为post_id参数传递给视图
# - '/comment/' 固定文本部分
' post/<int:post_id>/comment/ ' ,
# zy:对应的视图函数,处理添加评论的请求
views . add_comment ,
# zy:URL模式的名称, 用于在模板和代码中进行反向解析
name = ' add_comment '
) ,
]