zoukankan      html  css  js  c++  java
  • django-URL之include函数(五)

    三种格式:
    (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')                
    }
  • 相关阅读:
    Java 多态
    HDFS读写原理
    HDFS详解
    Servlet基础
    Tomcat
    HTTP简介
    JDBC技术
    final、finally和finalize
    java 中的权限修饰符
    进程、线程、线程状态、多线程实现方法
  • 原文地址:https://www.cnblogs.com/xiximayou/p/11732234.html
Copyright © 2011-2022 走看看