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)

project.tar.gz (3.3 KB ) - added by Ryan Fugger 12 years ago.
propagate_unnamed_groups_to_included_urlconfs.patch (980 bytes ) - added by stefantalpalaru 12 years ago.
the fix
propagate_unnamed_groups_to_included_urlconfs2.patch (2.6 KB ) - added by stefantalpalaru 12 years ago.
better fix and test case

Download all attachments as: .zip

Change History (11)

by Ryan Fugger, 12 years ago

Attachment: project.tar.gz added

by stefantalpalaru, 12 years ago

the fix

comment:1 by stefantalpalaru, 12 years ago

Cc: stefantalpalaru added
Has patch: set
Triage Stage: UnreviewedAccepted

See the attached patch for a simple fix. I've tried to write a test for regressiontests but gave up in the process.

by stefantalpalaru, 12 years ago

better fix and test case

comment:2 by stefantalpalaru, 12 years ago

Better patch that only adds the unnamed matches from the parent pattern. I've also added a test.

comment:3 by Eduardo Cereto, 12 years ago

Cc: eduardocereto@… added

comment:4 by Chris Beaven, 12 years ago

Resolution: wontfix
Status: newclosed
Type: BugNew 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 Ryan Fugger, 12 years ago

Resolution: wontfix
Status: closedreopened
Type: New featureBug

@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:

  1. 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.
  1. 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 Aymeric Augustin, 12 years ago

Status: reopenednew

comment:7 by Tim Graham, 10 years ago

Has patch: unset

comment:8 by Bas Peschier, 10 years ago

Resolution: duplicate
Status: newclosed

This is a duplicate of #12943 and was recently fixed.

Note: See TracTickets for help on using tickets.
Back to Top