Django框架学习-demo模块中总路径设置
1 """demo URL Configuration 2 3 The `urlpatterns` list routes URLs to views. For more information please see: 4 https://docs.djangoproject.com/en/1.11/topics/http/urls/ 5 Examples: 6 Function views 7 1. Add an import: from my_app import views 8 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') 9 Class-based views 10 1. Add an import: from other_app.views import Home 11 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 12 Including another URLconf 13 1. Import the include() function: from django.conf.urls import url, include 14 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) 15 """ 16 from django.conf.urls import url, include 17 from django.contrib import admin 18 19 from users import views 20 21 urlpatterns = [ 22 url(r'^admin/', admin.site.urls), 23 24 # users应用的总路由:将users子应用的全部路由包含的项目中的总路由 25 # url(r'^users/', include('users.urls')), 26 27 # 演示总路由一级匹配直接找视图 28 # url(r'^users/index/$',views.index), 29 30 # 演示路由的命名空间和reverse反向解析 31 url(r'^users/', include('users.urls', namespace='users')), 32 33 # 演示请求和响应对象 34 url(r'^', include('request_response.urls')) 35 ]