Django-路由的分发
作者:互联网
不同的app路由都统一集中到了一块,如果项目简单还好,项目复杂,url文件就会变得特别臃肿。
我们可以用django的include函数完成这个操作
from django.urls import path,include
path('1级路由/',include(视图模块))
修改主路由,开头导入include
from django.contrib import admin
from django.urls import path,include #导入include
#第一步导入路由
from aaa import urls as aaa_view
from bbb import urls as bbb_view
urlpatterns = [
path('admin/', admin.site.urls),
#aaa系统路由
path('aaa/',include(aaa_view)),
# bbb系统路由
path('bbb/',include(bbb_view)),
]```
标签:分发,aaa,bbb,Django,import,path,include,路由 来源: https://www.cnblogs.com/caoxiaowei/p/16418725.html