Django 正则URL
Django 正则URL
URL编写
📋urlpatterns = [ path('admin/', admin.site.urls), path('login',views.login), path('signup.html',views.signup), path('home',views.home.as_view()), path('dict',views.dict), # re_path('detail',views.detail), re_path('detail-(?P<nid>\d+)-(?P<uid>\d+).html',views.detail), #动态的路由 ]
views代码
📋def detail(request,nid,uid): return HttpResponse(nid)
前端结果展示
来源:https://www.cnblogs.com/yjc-z/p/12014465.html