django-URL之include函数(五)

前端之家收集整理的这篇文章主要介绍了django-URL之include函数(五)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

三种格式:
(1)incude(module,namespace=None)

from django.urls import path,include
from book  urls
urlpatterns={
  path('',include(urls))                
}

module:模型文件,namespace:实例命名空间

(2)include(pattern_list)

from .  views
extractpatterns='index'),path(index/',1)">''home/,}
urlpatterns=)                
}

pattern_list:可迭代的path()或re_path()清单

(3)include((pattern_list,app_namespace),namespace)

app_namespace:app命名空间

)   
  path() 
}
urlpatterns=newsapp')),1)">)                
}

 

猜你在找的Django相关文章