django篇-路由系统介绍

路由分为两种静态路由和动态路由

path(‘admin/‘, admin.site.urls),path(‘test/‘, views.test_view),path(‘login/‘, views.login_view),# re_path(r‘^articles/2003/$‘, views.special_case_2003),# re_path(r‘^articles/(?P<year>[0-9]{4})/$‘, views.article_archive),#re_path(r‘^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/$‘, views.article_archive)# re_path(r‘^articles/([0-9]{4})/([0-9]{2})/$‘, views.article_archive2)re_path(r‘^articles/(?P<arg1>[0-9]{4})/(?P<arg2>[0-9]{2})/(?P<ddd>[\w-]+)/$‘, views.article_archive3)Django的路由匹配心法自定义路由converter管理多个URL文件省略重复的URL

相关推荐