python url配置单独放在某个应用目录中

  文件目录:

  python url配置单独放在某个应用目录中

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

    python url配置单独放在某个应用目录中

  此时,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'),

]

  

  

  

你可能感兴趣的:(python)