from django.urls import path from . import views # 设置应用命名空间,用于URL反向解析 app_name = "comments" # URL模式列表 urlpatterns = [ #文章评论提交接口 # 捕获整数类型article_id参数,映射到CommentPostView视图 path( 'article//postcomment', views.CommentPostView.as_view(), name='postcomment'),# URL名称,模板中可通过{% url 'comments:postcomment' article_id %}调用 ]