路由的分发 include
主程序的URL中,导入include
from django.conf.urls import url,include #app用两个分别叫(luyou,luyou1) urlpatterns = [ url(r'^cmdb/', include('luyou.urls')), url(r'^monitor/',include('luyou1.urls')), ]
app---------luyou的URL中(创建app的命令: python manage.py startapp luyou)
from luyou import views urlpatterns = [ url(r'^index/', views.index), ] luyou对应views.py中 def index(request): return HttpResponse('luyou')
另一个app---------luyou1的URL中(创建app的命令: python manage.py startapp luyou1)
相关推荐:《Python视频教程》
from luyou1 import views urlpatterns = [ url(r'^index/', views.index), ] luyou1对应views.py中 def index(request): return HttpResponse('luyou1')
预期
相关推荐: