路由的分发 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)
from luyou1 import views urlpatterns = [ url(r'^index/', views.index), ] luyou1对应views.py中 def index(request): return HttpResponse('luyou1')
预期
相关推荐:
Django如何进行urls映射管理
神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试