#31070: Add a check for URLconfs that mix named and unnamed capture groups
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Baptiste
| Mispelon
Type: New feature | Status: assigned
Component: Core (System | Version: master
checks) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Carlton Gibson):
OK, nearly with you. Thank you for your patience.
> Consider the case of someone who has a working mixed-pattern URLConf,
something like:
> `^entry/(?P<pk>\d+)(\.html|/)$`
In this case, when is the `(\.html/)` bit ever used? Just as an optional
format maybe `(\.html)?` — so I can add it or not but it never affects the
view in any real way? (I guess the question is "Why would I put it in a
group at all if it were not **for** something?")
If this kind of usage makes sense (which I guess in the "optional format"
example it maybe does — but even then... surely the view wants that
info!!!) then I can't see that we should raise a warning, again, for
patterns that have been working forever™.
The possible error it would be worth catching is "You do know your non-
named groups won't ever be used".
My concern here is a lot of warnings for perfectly valid patterns. (Would
folks use groups not meaning for them to be passed to the view?)
--
Ticket URL: <https://code.djangoproject.com/ticket/31070#comment:9>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.55bbc76ade1659affefbf0a77758b396%40djangoproject.com.