Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#16109 closed Bug (fixed)

Inconsistency in docs: Leading zero of numbers in URLconf

Reported by: wegener92@… Owned by: nobody
Component: Documentation Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In https://docs.djangoproject.com/en/1.3/topics/http/urls/#example, the suggested regex for an article / numbers in a url is

r'^articles/(\d{4})/(\d{2})/(\d+)/$'

But in https://docs.djangoproject.com/en/1.3/ref/models/instances/#django.db.models.permalink, it says

r'/archive/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$'

In particular, the first expression allows only 05 for a month, the second 05 and 5, which leads to multiple urls for the same content. Additionally, the example get_absolute_url method wouldn't match the first expression (\d{2}) for dates with month or day below 10.

I first thought this is a "support issue", not a bug, so you may want to read my post on stackoverflow.com. It was recommended to me to submit bug report because of this inconsistency in the docs.

Attachments (1)

16109.diff (3.0 KB) - added by minarets 4 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 4 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Rather minor, but why not.

comment:2 Changed 4 years ago by julien

  • Type changed from Uncategorized to Bug
  • UI/UX unset

Changed 4 years ago by minarets

comment:3 Changed 4 years ago by minarets

  • Has patch set

Patched the docs to not have any ambiguous date urls (so no d{1,2}).

comment:4 Changed 4 years ago by adamnelson

  • Triage Stage changed from Accepted to Ready for checkin

patch applies cleanly and text makes sense

comment:5 Changed 4 years ago by ubernostrum

  • Resolution set to fixed
  • Status changed from new to closed

In [16811]:

Fixed #16109: Corrected an inconsistency in URLconf examples for matching a numeric month.

comment:6 Changed 4 years ago by ubernostrum

In [16812]:

[1.3.X] Fixed #16109: Corrected an inconsistency in URLconf examples for matching a numeric month. Backport of [16811] from trunk.

Note: See TracTickets for help on using tickets.
Back to Top