#30995: Feature/docs: how should url converters decline to match for a named
route?
-------------------------------------+-------------------------------------
Reporter: Jack Cushman | Owner: Jack
| Cushman
Type: New feature | Status: assigned
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: reverse, urls, | Triage Stage: Accepted
converter |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jack Cushman):
* has_patch: 0 => 1
Comment:
Here's a PR for review: [https://github.com/django/django/pull/12121 PR]
Simon, thanks for finding those related links! This ticket is distinct
from #16774, though. That one is about allowing views to raise
`ContinueResolving` internally once control is handed off to them, which
would be a much larger change to the internal resolution logic.
This one involves adding a single `try: ... except ValueError: continue`
to the {{{reverse()}}} logic to give url converters an explicit way to
deny a match in {{{to_url()}}}, which they can already do by returning
empty string or other non-regex-matching response, and which is consistent
with the handling of {{{ValueError}}} in {{{to_python()}}}. As you can see
from the new tests in the PR, Django already supports type-based reverse
resolution in a variety of cases, and this PR just fills in one edge case.
I do see how the two are related, though! Depending why someone wants to
raise {{{ContinueResolving}}} from a view, they might be able to solve the
same problem by raising {{{ValueError}}} from {{{converter.to_python}}}
since converters landed in Django 2.0. That's not affected one way or
another by this patch to {{{reverse()}}}, though.
--
Ticket URL: <https://code.djangoproject.com/ticket/30995#comment:7>
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/066.64d51dc38130c6ce5dc1da7304fe9ca2%40djangoproject.com.