一 Django中路由的作用
URL配置(URLconf)就像Django 所支撑网站的目录。它的本质是URL与要为该URL调用的视图函数之间的映射表;你就是以这种方式告诉Django,对于客户端发来的某个URL调用哪一段逻辑代码对应执行
典型的例子:
from django.urls import path urlpatterns = [
path('articles', views.special),
]
articles这个路由对应着视图函数中special这个方法,浏览器输入这个链接,就会响应到special这个函数来执行
二 简单的路由配置
from django.conf.urls import url urlpatterns = [
url(正则表达式, views视图函数,参数,别名),
]
- 第一个参数:正则表达式:一个正则表达式字符串
- 第二个参数:views视图函数:一个可调用对象,通常为一个视图函数或一个指定视图函数路径的字符串
- 第三个参数:参数:可选的要传递给视图函数的默认参数(字典形式)
- 第四个参数:别名:url的别名,用在前端。一个可选的name参数
from django.urls import path,re_path
from app01 import views urlpatterns = [
^以什么开头的意思,/普通字符,$是所以什么结尾的意思。完全匹配
re_path(r'^articles/2003/$', views.special_case_2003),
任意0-9的数字重复4次
re_path(r'^articles/[0-9]{4}/$', views.year_archive),
在视图函数里希望拿到输入的比如1995这个内容。视图函数收的都是字符串。url可以当做路径参数传到视图函数里。
re_path(r'^articles/([0-9]{4})/$', views.year_archive), re_path(r'^articles/([0-9]{4})/[0-9]{2}/$', views.month_archive), re_path(r'^articles/([0-9]{4})/([0-9]{2})/$', views.month_archive),
re_path(r'^articles/([0-9]{4})/([0-9]{2})/([0-9]+)/$', views.article_detail),
]
注意:
- 若要从URL 中捕获一个值,只需要在它周围放置一对圆括号。
- 不需要添加一个前导的反斜杠,因为每个URL 都有。例如,应该是
^articles
而不是^/articles
。 - 每个正则表达式前面的'r' 是可选的但是建议加上。它告诉Python 这个字符串是“原始的” —— 字符串中任何字符都不应该转义
- urlpatterns中的元素按照书写顺序从上往下逐一匹配正则表达式,一旦匹配成功则不再继续
示例:
'''
一些请求的例子: /articles/2005/03/ 请求将匹配列表中的第三个模式。Django 将调用函数views.month_archive(request, '2005', '03')。
/articles/2005/3/ 不匹配任何URL 模式,因为列表中的第三个模式要求月份应该是两个数字。
/articles/2003/ 将匹配列表中的第一个模式不是第二个,因为模式按顺序匹配,第一个会首先测试是否匹配。请像这样*插入一些特殊的情况来探测匹配的次序。
/articles/2003 不匹配任何一个模式,因为每个模式要求URL 以一个反斜线结尾。
/articles/2003/03/03/ 将匹配最后一个模式。Django 将调用函数views.article_detail(request, '2003', '03', '03')。 '''
APPEND_SLASH
# 是否开启URL访问地址后面不为/跳转至带有/的路径的配置项
APPEND_SLASH=True
Django settings.py配置文件中默认没有 APPEND_SLASH 这个参数,但 Django 默认这个参数为 APPEND_SLASH = True。 其作用就是自动在网址结尾加'/'。
其效果就是:
我们定义了urls.py:
from django.conf.urls import url
from app01 import views urlpatterns = [
url(r'^blog/$', views.blog),
]
访问 http://www.example.com/blog 时,默认将网址自动转换为 http://www.example/com/blog/ 。
如果在settings.py中设置了 APPEND_SLASH=False,此时我们再请求 http://www.example.com/blog 时就会提示找不到页面。
三 有名分组 name groups
import re
ret=re.search('(?P<year>[0-9]{4})/([0-9]{2})','2012/12')
print(ret.group())
print(ret.group(1))
print(ret.group(2))
print(ret.group('year'))
上面的示例使用简单的、没有命名的正则表达式组(通过圆括号)来捕获URL 中的值并以位置 参数传递给视图。在更高级的用法中,可以使用命名的正则表达式组来捕获URL 中的值并以关键字 参数传递给视图。
在Python 正则表达式中,命名正则表达式组的语法是(?P<name>pattern)
,其中name
是组的名称,pattern
是要匹配的模式。
from app02 import views
from django.conf.urls import url urlpatterns = [
#无名分组
url(r'^article/\d{4}', views.year) , url(r'^article/(\d{4})$', views.year2),
如果有多个匹配一样的时候,谁放在上面就匹配谁,上面的就会把下面的覆盖了
正则加上括号,就是分组,会把分组的内容作为year2函数的参数传进去
url(r'^article/(\d{4})/(\d{2})$', views.year_month), # 有名分组(就是给分组起个名字,这样定义的好处就是按照关键字参数去传参了,指名道姓的方式)
url(r'^article/(?P<year>\d{4})/(?P<month>\d{2})$', views.year_month_hasname)
]
下面是以上URLconf 使用命名组的重写:
from django.urls import path,re_path from app01 import views urlpatterns = [
re_path(r'^articles/2003/$', views.special_case_2003),
re_path(r'^articles/(?P<year>[0-9]{4})/$', views.year_archive),
re_path(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/$', views.month_archive),
re_path(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2})/$', views.article_detail),
]
#捕获到的数据都是str类型
#视图函数里可以指定默认值
url('blog/$', views.blog),
url('blog/(?P<num>[0-9]{1})', views.blog),
def blog(request,num=1):
print(num)
return HttpResponse('ok')
这个实现与前面的示例完全相同,只有一个细微的差别:捕获的值作为关键字参数而不是位置参数传递给视图函数。例如:
'''
/articles/2005/03/ 请求将调用views.month_archive(request, year='2005', month='03')函数,而不是views.month_archive(request, '2005', '03')。
/articles/2003/03/03/ 请求将调用函数views.article_detail(request, year='2003', month='03', day='03')。 '''
在实际应用中,这意味你的URLconf 会更加明晰且不容易产生参数顺序问题的错误 —— 你可以在你的视图函数定义中重新安排参数的顺序。当然,这些好处是以简洁为代价;
第三个参数的应用:
路由:
url(r'^index',views.index,{'name':'zrg'})
视图:
def index(request,name):
return HttpResponse(name)
第四个参数的应用:起别名!
路由:固定写法name=
别名,都是为了防止以后修改的时候发生大量的相关操作。
用homepage替换index路径的意思。
路由:
url(r'^index/', views.index,name='homepage'),
template: 前端我们写的是别名,到了后端又会对应过来。
发给前端的一定是已经渲染好的
<form action={% url 'homepage' %} method="post">
<input type="text" name="user">
<input type="password" name="pwd">
<input type="submit" name="submit">
</form>
views: 通过模板语言把浏览器不认识的东西换成认识的东西就是render做的事。
def index(request):
if request.method == 'GET':
return render(request,'login.html')
elif request.method == 'POST':
# 获取前端提交的数据
username = request.POST.get('user')
pwd = request.POST.get('pwd')
# 与数据库的数据进行校验
if username == 'zrg' and pwd == '':
return HttpResponse('登录成功')
四 路由分发
urls.py文件是在全局项目下面。但是如果一个项目功能很多,有多个app。如果多个的都写在urls.py里面会造成干扰冲突,没有解耦。
基于此,我们做路由分发:
1、在每个app里写自己的urls.py
from django.conf.urls import url,include
from app01 import views
urlpatterns = [
url(r'^new/story',views.introduce),
]
app里的视图函数:
from django.shortcuts import render,HttpResponse # Create your views here.
def introduce(request):
return HttpResponse('路由分发1')
2、全局的urls.py做个指派: include的作用就是映射
from django.conf.urls import url,include
from django.contrib import admin urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^app01/', include('app01.urls')), 以app01开头的去app01里面自己去分发。
]
通过http://127.0.0.1:8000/app01/new/story来访问。
Django1.1版本的分发
from django.conf.urls import url,include
#主urls
from django.urls import path,re_path,include
from app01 import views
from app01 import urls
urlpatterns = [
# re_path(r'^app01/',include('app01.urls')),#行
# re_path(r'^app01/&',include('app01.urls')),#不行
# path('app01/',include('app01.urls')),#行
#path('app01/', include(urls)),
]
在app01里创建一个urls
from django.urls import path,re_path
from app01 import views
urlpatterns = [
re_path(r'^test/(?P<year>[0-9]{2})/$',views.url_test),
]
五 反向解析
在使用Django 项目时,一个常见的需求是获得URL 的最终形式,以用于嵌入到生成的内容中(视图中和显示给用户的URL等)或者用于处理服务器端的导航(重定向等)。人们强烈希望不要硬编码这些URL(费力、不可扩展且容易产生错误)或者设计一种与URLconf 毫不相关的专门的URL 生成机制,因为这样容易导致一定程度上产生过期的URL。
在需要URL 的地方,对于不同层级,Django 提供不同的工具用于URL 反查:
- 在模板中:使用url 模板标签。
- 在Python 代码中:使用
from django.urls import reverse()函数
urls.py
from django.urls import path,re_path
from app01 import views
urlpatterns = [
re_path(r'^test/(?P<year>[0-9]{2})/(?P<month>[0-9]{2})/$',views.url_test,name='test'),
]
html
<a href="{% url 'test' 10 23 %}">哈哈</a>
视图函数中:
from django.shortcuts import render, HttpResponse,redirect,reverse
def url_test(request,year,month):
print(year)
print(month)
url=reverse('test',args=(10,20))
print(url)
return HttpResponse('ok')
总结:1 在html代码里{% url "别名" 参数 参数%}
2 在视图函数中:
2.1 url=reverse('test')
2.2 url=reverse('test',args=(10,20))
当命名你的URL 模式时,请确保使用的名称不会与其它应用中名称冲突。如果你的URL 模式叫做comment
,而另外一个应用中也有一个同样的名称,当你在模板中使用这个名称的时候不能保证将插入哪个URL。在URL 名称中加上一个前缀,比如应用的名称,将减少冲突的可能。我们建议使用myapp-comment
而不是comment
。
六 名称空间
命名空间(英语:Namespace)是表示标识符的可见范围。一个标识符可在多个命名空间中定义,它在不同命名空间中的含义是互不相干的。这样,在一个新的命名空间中可定义任何标识符,它们不会与任何已有的标识符发生冲突,因为已有的定义都处于其它命名空间中。
from django.urls import path,re_path,include
urlpatterns = [
path('app01/', include('app01.urls')),
path('app02/', include('app02.urls'))
]
app01 的urls.py
from django.urls import path,re_path
from app01 import views
urlpatterns = [
re_path(r'index/',views.index,name='index'),
]
app02 的urls.py
from django.urls import path, re_path, include
from app02 import views urlpatterns = [
re_path(r'index/', views.index,name='index'), ]
app01的视图函数
def index(request):
url=reverse('index')
print(url)
return HttpResponse('index app01')
app02的视图函数
ef index(request):
url=reverse('index')
print(url)
return HttpResponse('index app02')
这样都找index,app01和app02找到的都是app02的index
如何处理?在路由分发的时候指定名称空间
总urls.py在路由分发时,指定名称空间
path('app01/', include(('app01.urls','app01'))),
path('app02/', include(('app02.urls','app02')))
url(r'app01/',include('app01.urls',namespace='app01')),
url(r'app02/',include('app02.urls',namespace='app02'))
url(r'app01/',include(('app01.urls','app01'))),
url(r'app02/',include(('app02.urls','app02')))
在视图函数反向解析的时候,指定是那个名称空间下的
url=reverse('app02:index')
print(url)
url2=reverse('app01:index')
print(url2)
在模版里:
<a href="{% url 'app02:index'%}">哈哈</a>
七 django2.0版的path
django2.0的re_path和1.0的url一样
思考情况如下:
urlpatterns = [
re_path('articles/(?P<year>[0-9]{4})/', year_archive),
re_path('article/(?P<article_id>[a-zA-Z0-9]+)/detail/', detail_view),
re_path('articles/(?P<article_id>[a-zA-Z0-9]+)/edit/', edit_view),
re_path('articles/(?P<article_id>[a-zA-Z0-9]+)/delete/', delete_view),
]
考虑下这样的两个问题:
第一个问题,函数 year_archive
中year参数是字符串类型的,因此需要先转化为整数类型的变量值,当然year=int(year)
不会有诸如如TypeError或者ValueError的异常。那么有没有一种方法,在url中,使得这一转化步骤可以由Django自动完成?
第二个问题,三个路由中article_id都是同样的正则表达式,但是你需要写三遍,当之后article_id规则改变后,需要同时修改三处代码,那么有没有一种方法,只需修改一处即可?
在Django2.0中,可以使用 path
解决以上的两个问题。
基本示例
django2.0的re_path和1.0的url一样
思考情况如下:
urlpatterns = [
re_path('articles/(?P<year>[0-9]{4})/', year_archive),
re_path('article/(?P<article_id>[a-zA-Z0-9]+)/detail/', detail_view),
re_path('articles/(?P<article_id>[a-zA-Z0-9]+)/edit/', edit_view),
re_path('articles/(?P<article_id>[a-zA-Z0-9]+)/delete/', delete_view),
]
考虑下这样的两个问题:
第一个问题,函数 year_archive
中year参数是字符串类型的,因此需要先转化为整数类型的变量值,当然year=int(year)
不会有诸如如TypeError或者ValueError的异常。那么有没有一种方法,在url中,使得这一转化步骤可以由Django自动完成?
第二个问题,三个路由中article_id都是同样的正则表达式,但是你需要写三遍,当之后article_id规则改变后,需要同时修改三处代码,那么有没有一种方法,只需修改一处即可?
在Django2.0中,可以使用 path
解决以上的两个问题。
基本示例
这是一个简单的例子:
from django.urls import path
from . import views
urlpatterns = [
path('articles/2003/', views.special_case_2003),
path('articles/<int:year>/', views.year_archive),
path('articles/<int:year>/<int:month>/', views.month_archive),
path('articles/<int:year>/<int:month>/<slug>/', views.article_detail),
# path才支持,re_path不支持
path('order/<int:year>',views.order),
]
基本规则:
- 使用尖括号(
<>
)从url中捕获值。 - 捕获值中可以包含一个转化器类型(converter type),比如使用
<int:name>
捕获一个整数变量。若果没有转化器,将匹配任何字符串,当然也包括了/
字符。 - 无需添加前导斜杠。
以下是根据 2.0官方文档 而整理的示例分析表:(跟上面url的匹配关系)
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABhgAAAIQCAYAAABzDmT/AAAgAElEQVR4Aezde2wT574v/O/Z77KPtOw/7G5t5+jYaOMgESoSpATUZFUN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Kk4een5D4aplzXOowAFKEABCjwNAdsTxch9MJgcyLBADQAMEphIzXDGdxhC7EGg88oPYLnm2UhsuZmz6gxslo3YoumrV/xRb7WdxfxYkYz4csS1KEABClCAAiNfwAy4GjZhg9QFYWh27Xmb8UmpWGkRsGWkAY1KPX0/HrW14FHI6g5YtP3Yhyz7FX0Q7mNL2fqIQIxyhOmz1mNxrg1tFw/hhKZGuzigdVunWoECSMWev5QF+jYwT8bnu4owr/KikgzaTm/CudSw5xFzGpbnWbDlqgdjC7bj06WTIXZDqZa2ZGJarOcX1w9YWaEdryG4O7WESOjCmTY1RaSW4LUYjTv9EWNvAUhKRioA/RiPAU6b9kLpRnWwoF7MjxPzxdqccbzcXT9EBhechajdVRKlwmkgUUeKeE3LAQaDBWNTkpHiTMPEjBQ4bDbYHEmDlitZs0qxLP06jugdpKUQEQ0n4jgerkIBClAgEYGnE2CAETnv5eNEZQc+PLgP2WHV97UtGCIza0ZmgR2X65WHBXmNKP3sWTPK8PWlsrBkjEjPTwUOhzWjkNeaWJQ7yBe0GdlLq6DtJjFsByEfTdYkpFhj3OVC1uYHClCAAhSgwCgSMFsBgwsWU5Tmg09C4fPAYhW7VdR72bG4fCYQ0v+BEQajD1ePnZJ/AArwG60Yn2IAWjQ/XvWSE+elLsX8mH05azY0pmHtLCe21Ie2oojdshFILa7GHvNGbDgtP8PYC2P/ONfskpMUoAAFKECBF17ACzgKK5B+fEVIgXB4YN6aOgPpaApZR3vslrwZIeMfxnGX124+DNNq/0uW1EykhxRiJ568b+Au7oQEBOQ0jBOwcoETG05rnzfsyFuyELNysqDs1rGqBnnvdeBM9SZctazH+e3J2DFTMc7Azi+rQlplmtIW4shGH5ZVN0k7MmSu163skFpUgZVZVuRkBArhc9aVon7NIan1w9gF74ecg4ijdkzAK4DOuJG5mKY8bxnT8MmuIiyWgx3LVuSqwYeIBAFbaiDwJPa67bcqgQMHpqUDbTqF79PK" alt="" width="1560" height="528" />
path转化器
文档原文是Path converters,暂且翻译为转化器。
Django默认支持以下5个转化器:
- str,匹配除了路径分隔符(
/
)之外的非空字符串,这是默认的形式 - int,匹配正整数,包含0。
- slug,匹配字母、数字以及横杠、下划线组成的字符串。
- uuid,匹配格式化的uuid,如 075194d3-6885-417e-a8a8-6c931e272f00。
- path,匹配任何非空字符串,包含了路径分隔符(/)(不能用?)
注册自定义转化器
对于一些复杂或者复用的需要,可以定义自己的转化器。转化器是一个类或接口,它的要求有三点:
-
regex
类属性,字符串类型
-
to_python(self, value)
方法,value是由类属性regex
所匹配到的字符串,返回具体的Python变量值,以供Django传递到对应的视图函数中。 -
to_url(self, value)
方法,和to_python
相反,value是一个具体的Python变量值,返回其字符串,通常用于url反向引用。
例子
class FourDigitYearConverter:
regex = '[0-9]{4}'
def to_python(self, value):
return int(value)
def to_url(self, value):
return '%04d' % value
使用register_converter
将其注册到URL配置中:
from django.urls import register_converter, path
from . import converters, views
register_converter(converters.FourDigitYearConverter, 'yyyy')
urlpatterns = [
path('articles/2003/', views.special_case_2003),
path('articles/<yyyy:year>/', views.year_archive),
...
]