[Django] #22781: Improve named regular-expression groups example to capture URL bits

5 views
Skip to first unread message

Django

unread,
Jun 6, 2014, 2:28:12 PM6/6/14
to django-...@googlegroups.com
#22781: Improve named regular-expression groups example to capture URL bits
-------------------------------------+-------------------------------------
Reporter: oubiga | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: 1.6
Component: Documentation | Keywords: url, regular,
Severity: Normal | expression, regex, group
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Hi folks!

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.

Django

unread,
Jun 6, 2014, 3:44:28 PM6/6/14
to django-...@googlegroups.com
#22781: Improve named regular-expression groups example to capture URL bits
-------------------------------------+-------------------------------------
Reporter: oubiga | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: 1.6
Component: Documentation | Resolution:
Severity: Normal | Triage Stage:
Keywords: url, regular, | Unreviewed
expression, regex, group | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by mardini):

* 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>

Django

unread,
Jun 6, 2014, 3:57:49 PM6/6/14
to django-...@googlegroups.com
#22781: Improve named regular-expression groups example to capture URL bits
-------------------------------------+-------------------------------------
Reporter: oubiga | Owner: nobody
Type: | Status: closed
Cleanup/optimization | Version: 1.6
Component: Documentation | Resolution: wontfix

Severity: Normal | Triage Stage:
Keywords: url, regular, | Unreviewed
expression, regex, group | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* 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>

Reply all
Reply to author
Forward
0 new messages