Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#28627 closed Uncategorized (fixed)

path-urls documentation implies implicit converter-types

Reported by: Christopher Schäpers Owned by: nobody
Component: Documentation Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The documentation for the new path() urls somewhat implies that if you have a named value in an url without a converter type, but with the name of a converter-type it takes the name of the value, and uses it as its converter-type.

E.g.

path('articles/<slug>/', …)

would only match a slug, and would pass the value on as "slug".
(As seen here: https://docs.djangoproject.com/en/dev/topics/http/urls/#example )

This is wrong, as mentioned below (easy to miss, if you're eager to test stuff out):

If a converter isn’t included, any string, excluding a / character, is matched.

However it doesn't help, that the example uses "slug" as a name, and states

/articles/2003/03/building-a-django-site/

would match the last example, even though

/articles/2003/03/building+a~django@site/

would match it just as well.


Simple fix would be to just change the example from

articles/<int:year>/<int:month>/<slug>/

to

articles/<int:year>/<int:month>/<slug:slug>/

because I suppose the implicit converter types aren't a feature of 2.0.

(If someone points me to the right repo, I can do the little documentation change myself)

Change History (3)

comment:1 by Christopher Schäpers, 7 years ago

Has patch: set
Last edited 7 years ago by Tim Graham (previous) (diff)

comment:2 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: newclosed

In 6da1407:

Fixed #28627 -- Added slug converter to some path() examples in docs.

comment:3 by Tim Graham <timograham@…>, 7 years ago

In ecea60f:

[2.0.x] Fixed #28627 -- Added slug converter to some path() examples in docs.

Backport of 6da140724dba546d2f3aced1308e617747b0385c from master

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