Documentation shows
[https://docs.djangoproject.com/en/dev/topics/http/urls/#named-groups]:
{{{
from django.conf.urls import url
urlpatterns = [
url(r'^articles/2003/$', 'news.views.special_case_2003'),
url(r'^articles/(?P<year>[0-9]{4})/$', 'news.views.year_archive'),
url(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/$',
'news.views.month_archive'),
url(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2})/$',
'news.views.article_detail'),
]
}}}
I think this would be more flexible:
{{{
from django.conf.urls import url
urlpatterns = [
url(r'^articles/2003/$', 'news.views.special_case_2003'),
url(r'^articles/(?P<year>[0-9]{4})/$', 'news.views.year_archive'),
url(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/$',
'news.views.month_archive'),
url(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/(?P<day>[0-9]{1,2})/$',
'news.views.article_detail'),
]
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22781>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Well, I think the wide-spread standard on the web is to use a two-digit
month, 01 through 12, and a two-digit day, 01 through 31 in URLs dates.
--
Ticket URL: <https://code.djangoproject.com/ticket/22781#comment:1>
* status: new => closed
* resolution: => wontfix
Comment:
The format used in the example also has the advantage of being
unambiguous. It's a bad practice to have multiple URLs pointing to the
same page, and that would be possible with the lax format.
--
Ticket URL: <https://code.djangoproject.com/ticket/22781#comment:2>