路由分发
1、项目urls.py
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
from django.conf.urls import url,include from django.contrib import admin from django.views.static import serve from cnblog_s9 import settings from blog import views
urlpatterns = [ url(r"blog/",include("blog.url")), ]
2、app下创建url.py(引入与上面一致)
urlpatterns = [ url("(\w+)",views.homesite), # homesite(request) ]
基本使用 urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^index/', views.index), url(r"^yuan/",([ ],None,None)), # 注意形式,本质!!! ] 路由分发 url(r"^yuan/", ([ url(r'^test01/', ([ url(r'^test04/', test04), url(r'^test05/', test05), ], None, None)), url(r'^test02/', test02), url(r'^test03/', test03), ], None, None) ) urlpatterns=[ url(r"^yuan/",([ url(r"^test01/",test01") ],None,None,)) ] yuan/test01/ 如果有^ yuan后面必须是test01 ,没有^,只要后面是test01就可以