Re: [Django] #36796: URL resolution breaks if route defined with lazy string and uses an include

11 views
Skip to first unread message

Django

unread,
Dec 12, 2025, 10:14:18 AM12/12/25
to django-...@googlegroups.com
#36796: URL resolution breaks if route defined with lazy string and uses an include
------------------------------------+------------------------------------
Reporter: Andrea Angelini | Owner: (none)
Type: Bug | Status: new
Component: Core (URLs) | Version: 6.0
Severity: Release blocker | Resolution:
Keywords: gettext_lazy, lazy | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+------------------------------------
Comment (by Andrea Angelini):

Amended like following fixes this issue:

{{{
elif path.startswith(str(self._route)):
return path.removeprefix(str(self._route)), (), {}
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36796#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 12, 2025, 10:19:05 AM12/12/25
to django-...@googlegroups.com
#36796: URL resolution breaks if route defined with lazy string and uses an include
------------------------------------+------------------------------------
Reporter: Andrea Angelini | Owner: (none)
Type: Bug | Status: new
Component: Core (URLs) | Version: 6.0
Severity: Release blocker | Resolution:
Keywords: gettext_lazy, lazy | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+------------------------------------
Comment (by Jake Howard):

I'd missed that lazy string were accepted, and surprised a test didn't
cover this behaviour.

Just handling the `elif` case won't quite work, since there's also the
endpoint case. Converting `self._route` to a string (as part of `match`,
rather than the constructor so it's evaluated in the correct context)
sounds like the right solution. It'd be nice if the conversion only
happens once per `match` to avoid unnecessary extra work.
--
Ticket URL: <https://code.djangoproject.com/ticket/36796#comment:4>

Django

unread,
Dec 12, 2025, 10:28:29 AM12/12/25
to django-...@googlegroups.com
#36796: URL resolution breaks if route defined with lazy string and uses an include
------------------------------------+------------------------------------
Reporter: Andrea Angelini | Owner: (none)
Type: Bug | Status: new
Component: Core (URLs) | Version: 6.0
Severity: Release blocker | Resolution:
Keywords: gettext_lazy, lazy | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+------------------------------------
Comment (by Andrea Angelini):

I agree with you that it should be converted to a string as part of
`match`
--
Ticket URL: <https://code.djangoproject.com/ticket/36796#comment:5>

Django

unread,
Dec 12, 2025, 10:34:19 AM12/12/25
to django-...@googlegroups.com
#36796: URL resolution breaks if route defined with lazy string and uses an include
------------------------------------+------------------------------------
Reporter: Andrea Angelini | Owner: (none)
Type: Bug | Status: new
Component: Core (URLs) | Version: 6.0
Severity: Release blocker | Resolution:
Keywords: gettext_lazy, lazy | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+------------------------------------
Comment (by Andrea Angelini):

In the endpoint seems to work though because `gettext_lazy('test') ==
'test'` return `True`
--
Ticket URL: <https://code.djangoproject.com/ticket/36796#comment:6>

Django

unread,
Dec 14, 2025, 12:14:08 AM12/14/25
to django-...@googlegroups.com
#36796: URL resolution breaks if route defined with lazy string and uses an include
-------------------------------------+-------------------------------------
Reporter: Andrea Angelini | Owner: Kundan
| Yadav
Type: Bug | Status: assigned
Component: Core (URLs) | Version: 6.0
Severity: Release blocker | Resolution:
Keywords: gettext_lazy, lazy | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Kundan Yadav):

* owner: (none) => Kundan Yadav
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36796#comment:7>

Django

unread,
Dec 15, 2025, 2:53:19 PM12/15/25
to django-...@googlegroups.com
#36796: URL resolution breaks if route defined with lazy string and uses an include
-------------------------------------+-------------------------------------
Reporter: Andrea Angelini | Owner: Kundan
| Yadav
Type: Bug | Status: assigned
Component: Core (URLs) | Version: 6.0
Severity: Release blocker | Resolution:
Keywords: gettext_lazy, lazy | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* has_patch: 0 => 1

Comment:

[https://github.com/django/django/pull/20403 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/36796#comment:8>

Django

unread,
Dec 15, 2025, 4:43:04 PM12/15/25
to django-...@googlegroups.com
#36796: URL resolution breaks if route defined with lazy string and uses an include
-------------------------------------+-------------------------------------
Reporter: Andrea Angelini | Owner: Kundan
| Yadav
Type: Bug | Status: assigned
Component: Core (URLs) | Version: 6.0
Severity: Release blocker | Resolution:
Keywords: gettext_lazy, lazy | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36796#comment:9>

Django

unread,
Dec 19, 2025, 1:11:11 PM12/19/25
to django-...@googlegroups.com
#36796: URL resolution breaks if route defined with lazy string and uses an include
-------------------------------------+-------------------------------------
Reporter: Andrea Angelini | Owner: Kundan
| Yadav
Type: Bug | Status: assigned
Component: Core (URLs) | Version: 6.0
Severity: Release blocker | Resolution:
Keywords: gettext_lazy, lazy | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* needs_docs: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36796#comment:10>

Django

unread,
Dec 24, 2025, 2:50:15 PM12/24/25
to django-...@googlegroups.com
#36796: URL resolution breaks if route defined with lazy string and uses an include
-------------------------------------+-------------------------------------
Reporter: Andrea Angelini | Owner: Kundan
| Yadav
Type: Bug | Status: assigned
Component: Core (URLs) | Version: 6.0
Severity: Release blocker | Resolution:
Keywords: gettext_lazy, lazy | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* needs_better_patch: 1 => 0
* needs_docs: 1 => 0
* needs_tests: 1 => 0
* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36796#comment:11>

Django

unread,
Dec 26, 2025, 7:25:07 AM12/26/25
to django-...@googlegroups.com
#36796: URL resolution breaks if route defined with lazy string and uses an include
-------------------------------------+-------------------------------------
Reporter: Andrea Angelini | Owner: Kundan
| Yadav
Type: Bug | Status: closed
Component: Core (URLs) | Version: 6.0
Severity: Release blocker | Resolution: fixed
Keywords: gettext_lazy, lazy | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by nessita <124304+nessita@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"7bf3ac3ee255bcfe329e3203c7a2555b1275d506" 7bf3ac3e]:
{{{#!CommitTicketReference repository=""
revision="7bf3ac3ee255bcfe329e3203c7a2555b1275d506"
Fixed #36796 -- Handled lazy routes correctly in RoutePattern.match().

Coerce lazy route values to `str` at match time to support prefix and
endpoint matching when using `gettext_lazy()` route paths.

Regression in f920937c8a63df6bea220e4386f59cdb45b2e355.

Thanks to Andrea Angelini for the report, and to Jake Howard and Jacob
Walls for reviews.

Co-authored-by: Natalia <124304+...@users.noreply.github.com>
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36796#comment:12>

Django

unread,
Dec 26, 2025, 7:26:30 AM12/26/25
to django-...@googlegroups.com
#36796: URL resolution breaks if route defined with lazy string and uses an include
-------------------------------------+-------------------------------------
Reporter: Andrea Angelini | Owner: Kundan
| Yadav
Type: Bug | Status: closed
Component: Core (URLs) | Version: 6.0
Severity: Release blocker | Resolution: fixed
Keywords: gettext_lazy, lazy | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Natalia <124304+nessita@…>):

In [changeset:"d35daf8600a66c0ff20e36f82969df61a7fc4981" d35daf86]:
{{{#!CommitTicketReference repository=""
revision="d35daf8600a66c0ff20e36f82969df61a7fc4981"
[6.0.x] Fixed #36796 -- Handled lazy routes correctly in
RoutePattern.match().

Coerce lazy route values to `str` at match time to support prefix and
endpoint matching when using `gettext_lazy()` route paths.

Regression in f920937c8a63df6bea220e4386f59cdb45b2e355.

Thanks to Andrea Angelini for the report, and to Jake Howard and Jacob
Walls for reviews.

Co-authored-by: Natalia <124304+...@users.noreply.github.com>

Backport of 7bf3ac3ee255bcfe329e3203c7a2555b1275d506 from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36796#comment:13>
Reply all
Reply to author
Forward
0 new messages