#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)
PR