zoukankan      html  css  js  c++  java
  • python url配置单独放在某个应用目录中

      文件目录:

      

      将 urls.py 文件复制blog目录下:

        

      此时,blog文件夹下多了urls.py文件

      现在对比,两个urls.py文件:

      分离前:(只有website里有urls.py) 

    1 from django.conf.urls import include, url
    2 #from django.contrib import admin
    3 
    4 #"""
    5 urlpatterns = [
    6     #url(r'^admin/', include(admin.site.urls)),
    7     url(r'^blog/index/$', 'blog.views.index'),
    8     url(r'^blog/time/$', 'blog.views.time'),
    9 ]

      分离后:

      website的urls.py:

      

    from django.conf.urls import include, url
    #from django.contrib import admin
    
    #"""
    urlpatterns = [
        #url(r'^admin/', include(admin.site.urls)),
        #url(r'^blog/', 'blog.views.index'),
        url(r'^blog/',include('blog.urls')),
    ]

      blog的urls.py:

    from django.conf.urls import include, url
    #from django.contrib import admin
    
    urlpatterns = [
        #url(r'^admin/', include(admin.site.urls)),
        url(r'^index/$', 'blog.views.index'),
        url(r'^time/$', 'blog.views.time'),
    ]

      

      

      

  • 相关阅读:
    Leaf-spine data center architectures
    centreon 画图x轴乱码
    二分图匹配
    牛客练习赛17
    HDU-4550-贪心
    HDU-4511-ac自动机+dp
    UVA-11761-马尔可夫/记忆化搜索
    HDU-3853-期望/dp/坑
    HDU-4405-期望dp
    zoj-3329-期望/dp/方程优化
  • 原文地址:https://www.cnblogs.com/zychengzhiit1/p/4660291.html
Copyright © 2011-2022 走看看