文件目录:

  

  将 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'),
]

  

  

  

posted on 2015-07-20 01:13  新猪先生  阅读(349)  评论(0编辑  收藏  举报