使用 Django 开发 Web 应用程序时,为什么需要 URLconf?我正在尝试为 Web 应用程序创建一个,但我不明白它是如何编写的。:(
我从 djangoproject.com 获得了这个 URLconf 示例。有人能帮我解释一下这里的模式是如何写的吗?什么是 (\d{4})、(\d{2}) 和 (\d+)/ ?
from django.conf.urls import patterns, url, include
urlpatterns = patterns('',
(r'^articles/(\d{4})/$', 'news.views.year_archive'),
(r'^articles/(\d{4})/(\d{2})/$', 'news.views.month_archive'),
(r'^articles/(\d{4})/(\d{2})/(\d+)/$', 'news.views.article_detail'),
)