Opened 12 years ago
Closed 10 years ago
#18494 closed Bug (duplicate)
Positional arguments not passed to view functions in included urlconfs
Reported by: | Ryan Fugger | Owned by: | nobody |
---|---|---|---|
Component: | Core (URLs) | Version: | dev |
Severity: | Normal | Keywords: | urls, urlconf |
Cc: | arv@…, stefantalpalaru, eduardocereto@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The docs say "An included URLconf receives any captured parameters from parent URLconfs":
https://docs.djangoproject.com/en/1.4/topics/http/urls/#captured-parameters
But this only works currently for named arguments, not positional ones. I've included a small project demonstrating the issue, with a runnable test case.
Attachments (3)
Change History (11)
by , 12 years ago
Attachment: | project.tar.gz added |
---|
by , 12 years ago
Attachment: | propagate_unnamed_groups_to_included_urlconfs.patch added |
---|
comment:1 by , 12 years ago
Cc: | added |
---|---|
Has patch: | set |
Triage Stage: | Unreviewed → Accepted |
See the attached patch for a simple fix. I've tried to write a test for regressiontests but gave up in the process.
by , 12 years ago
Attachment: | propagate_unnamed_groups_to_included_urlconfs2.patch added |
---|
better fix and test case
comment:2 by , 12 years ago
Better patch that only adds the unnamed matches from the parent pattern. I've also added a test.
comment:3 by , 12 years ago
Cc: | added |
---|
comment:4 by , 12 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Type: | Bug → New feature |
This is not a bug -- the docs specifically cover the current behaviour: https://docs.djangoproject.com/en/1.4/topics/http/urls/#the-matching-grouping-algorithm.
I can't see how we could introduce this without being backwards incompatible (someone may be using a mix and expecting the conf to ignore the unnamed groups).
comment:5 by , 12 years ago
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
Type: | New feature → Bug |
@SmileyChris, thanks for pointing that out. However, the documentation at that link states that positional arguments will be passed to view functions as long as there are no named arguments. My included project demonstrates that this is not working properly with included urlconfs. I have two suggestions:
- Have positional arguments passed to views as long as there are no named arguments, even when they were captured before included urlconfs, as per the matching-grouping algorithm documentation at your link.
- If this is too difficult to implement, update the documentation at:
https://docs.djangoproject.com/en/1.4/topics/http/urls/#captured-parameters
to say that positional arguments are never passed to views when they are captured before included urlconfs. Also update the matching-grouping algorithm documentation to say this.
Thanks!
comment:6 by , 12 years ago
Status: | reopened → new |
---|
comment:7 by , 10 years ago
Has patch: | unset |
---|
comment:8 by , 10 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
This is a duplicate of #12943 and was recently fixed.
the fix