Django 路由分發django
當一個url請求過來以後
一、先到項目主目錄下的urls內。
二、由這個url作處理分發給其餘app內的urls。app
一級路由:主目錄urls內引入includeide
from django.conf.urls import url,include
urlpatterns = [ # 指定分發的app目錄名稱 url(r'^cmdb/',include("app01.urls")), url(r'^monitor/',include("app02.urls")), ]
二級路由:只查找本地urls內的路徑url
from django.conf.urls import url,include from app01 import views
urlpatterns = [ url(r'^login/', views.login), ]
其餘路由方案spa
urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^business$', views.business), #url(r'^business_add', views.business), ]
# 後面加入第三個參數,參數名稱爲indexx。 path('infdafddsfadsafdsafdsfdasfdsdex/', views.index,name='indexx') # <!-- 引用url返回的路徑變量,直接引用form表單內 --> <form action="{% url 'indexx' %}" method="POST">