标签:django mod news name 文件 ext include style port
三种格式:
(1)incude(module,namespace=None)
from django.urls import path,include from book import urls urlpatterns={ path(‘‘,include(urls)) }
module:模型文件,namespace:实例命名空间
(2)include(pattern_list)
from django.urls import path,include from . import views extractpatterns={ path(‘‘,views.index,name=‘index‘) , path(‘index/‘,views.index,name=‘index‘), path(‘‘home/,views.index,name=‘index‘), } urlpatterns={ path(‘index/‘,include(extracpatterns),name=‘index‘) }
pattern_list:可迭代的path()或re_path()清单
(3)include((pattern_list,app_namespace),namespace)
app_namespace:app命名空间
from django.urls import path,include from . import views extractpatterns={ path(‘‘,views.index,name=‘index‘) , path(‘index/‘,views.index,name=‘index‘) path(‘‘home/,views.index,name=‘index‘) } urlpatterns={ path(‘index/‘,include((extracpatterns,‘newsapp‘)),name=‘index‘) }
标签:django mod news name 文件 ext include style port
原文地址:https://www.cnblogs.com/xiximayou/p/11732234.html