在Django的1.8 urls.py是這樣寫的:爲什麼在Django 1.8有不同urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^articles/2003/$', views.special_case_2003),
url(r'^articles/([0-9]{4})/$', views.year_archive),
url(r'^articles/([0-9]{4})/([0-9]{2})/$', views.month_archive),
url(r'^articles/([0-9]{4})/([0-9]{2})/([0-9]+)/$', views.article_detail),
]
在Django的1.7 urls.py看起來是這樣的:
from django.conf.urls import patterns, url
from . import views
urlpatterns = patterns('',
url(r'^articles/2003/$', views.special_case_2003),
url(r'^articles/(\d{4})/$', views.year_archive),
url(r'^articles/(\d{4})/(\d{2})/$', views.month_archive),
url(r'^articles/(\d{4})/(\d{2})/(\d+)/$', views.article_detail),
)
燦有人解釋爲什麼在[(括號和關鍵字'模式')中有區別?
什麼是電子背景以及它如何實際顯示?
你看到改變了嗎?在doc中? '[0-9]'只能匹配0-9數字,而'\ d'也可以匹配Unicode數字字符。 –
單詞模式來自django 1.7文檔 – user1406647