分发

include()的三种使用方法

1、include(module, namespace=None)

2、include(pattern_list)  最常用

3、include((pattern_list, app_namespace), namesapce=None)

module -- 表示一种模型文件

namespace -- 表示实例命名空间

pattern_list -- 必须是一个可迭代的path() 或者 re_path() 清单

app_namesapce -- app命名空间

'''
At any point, your urlpatterns can “include” other URLconf modules. This
essentially “roots” a set of URLs below other ones.

'''

from django.urls import path,re_path,include
from app01 import views

urlpatterns = [
re_path(r'^admin/', admin.site.urls),
re_path(r'^blog/', include('blog.urls')),
]

 

posted @ 2021-11-01 17:06  wslfw  阅读(115)  评论(0)    收藏  举报