Re: [Django] #13525: URL Reverser chokes on nested groups

22 views
Skip to first unread message

Django

unread,
Feb 17, 2014, 3:24:01 PM2/17/14
to django-...@googlegroups.com
#13525: URL Reverser chokes on nested groups
-------------------------------+------------------------------------
Reporter: nickretallack | Owner: cypreess
Type: Bug | Status: assigned
Component: Core (URLs) | Version: 1.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by cypreess):

* owner: nobody => cypreess
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/13525#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 20, 2015, 3:34:40 AM3/20/15
to django-...@googlegroups.com
#13525: URL Reverser chokes on nested groups
-------------------------------+-------------------------------------
Reporter: nickretallack | Owner: bpeschier

Type: Bug | Status: assigned
Component: Core (URLs) | Version: 1.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+-------------------------------------
Changes (by bpeschier):

* owner: cypreess => bpeschier
* needs_docs: 0 => 1
* needs_tests: 0 => 1


Comment:

This is very hard to do, since both groups are captured and (if there was
a working implementation) should both be given to the reverser. There
would be a hard link between both groups since the inner group would
influence the outer group. Using an outer non-capturing group will work
and is recommended for this use case:

{{{
urlpatterns = patterns('',
url(r'^export1\.(?P<format>\w+)$', lambda request:
HttpResponse("THIS"), name='this'),
url(r'^export2(?:\.(?P<format>\w+))?$', lambda request:
HttpResponse("THAT"), name='that'),
)
}}}

I can update the tests and document the limitations that nested captured
groups are not supported.

--
Ticket URL: <https://code.djangoproject.com/ticket/13525#comment:8>

Django

unread,
Mar 20, 2015, 9:54:42 AM3/20/15
to django-...@googlegroups.com
#13525: URL Reverser chokes on nested groups
-------------------------------+-------------------------------------
Reporter: nickretallack | Owner: bpeschier
Type: Bug | Status: assigned
Component: Core (URLs) | Version: 1.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1

Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-------------------------------------
Changes (by bpeschier):

* has_patch: 0 => 1


Comment:

https://github.com/django/django/pull/4353

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

Django

unread,
Mar 20, 2015, 4:25:08 PM3/20/15
to django-...@googlegroups.com
#13525: URL Reverser chokes on nested groups
-------------------------------------+-------------------------------------
Reporter: nickretallack | Owner: bpeschier
Type: | Status: assigned
Cleanup/optimization |
Component: Documentation | Version: 1.1

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_docs: 1 => 0
* component: Core (URLs) => Documentation
* needs_tests: 1 => 0
* type: Bug => Cleanup/optimization


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

Django

unread,
Mar 21, 2015, 8:49:22 AM3/21/15
to django-...@googlegroups.com
#13525: Document how to reverse URL patterns with nested groups

-------------------------------------+-------------------------------------
Reporter: nickretallack | Owner: bpeschier
Type: | Status: assigned
Cleanup/optimization |
Component: Documentation | Version: 1.1
Severity: Normal | Resolution:
Keywords: | 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 timgraham):

* stage: Accepted => Ready for checkin


Comment:

Looks good, pending some cosmetic comments.

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

Django

unread,
Mar 23, 2015, 8:43:20 AM3/23/15
to django-...@googlegroups.com
#13525: Document how to reverse URL patterns with nested groups
-------------------------------------+-------------------------------------
Reporter: nickretallack | Owner: bpeschier
Type: | Status: closed

Cleanup/optimization |
Component: Documentation | Version: 1.1
Severity: Normal | Resolution: fixed

Keywords: | 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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"23a5d64f40b0f4a3fbfef7427ca793cb1df1034e" 23a5d64f]:
{{{
#!CommitTicketReference repository=""
revision="23a5d64f40b0f4a3fbfef7427ca793cb1df1034e"
Fixed #13525 -- Added tests and docs for nested parameters in URL
patterns.

When reversing, only outer parameters are used if captured parameters are
nested. Added tests to check the edge cases and documentation for the
behavior with an example to avoid it.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/13525#comment:12>

Django

unread,
Mar 23, 2015, 8:44:29 AM3/23/15
to django-...@googlegroups.com
#13525: Document how to reverse URL patterns with nested groups
-------------------------------------+-------------------------------------
Reporter: nickretallack | Owner: bpeschier
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: 1.1
Severity: Normal | Resolution: fixed
Keywords: | 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 Tim Graham <timograham@…>):

In [changeset:"015a9b928af233ca036b93a4d7eecf18f15cbc2b" 015a9b9]:
{{{
#!CommitTicketReference repository=""
revision="015a9b928af233ca036b93a4d7eecf18f15cbc2b"
[1.8.x] Fixed #13525 -- Added tests and docs for nested parameters in URL
patterns.

When reversing, only outer parameters are used if captured parameters are
nested. Added tests to check the edge cases and documentation for the
behavior with an example to avoid it.

Backport of 23a5d64f40b0f4a3fbfef7427ca793cb1df1034e from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/13525#comment:13>

Reply all
Reply to author
Forward
0 new messages