Opened 3 years ago

Last modified 8 months ago

#18494 new Bug

Positional arguments not passed to view functions in included urlconfs

Reported by: rfugger Owned by: nobody
Component: Core (URLs) Version: master
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


The docs say "An included URLconf receives any captured parameters from parent URLconfs":

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 rfugger 3 years ago.
propagate_unnamed_groups_to_included_urlconfs.patch (980 bytes) - added by stefantalpalaru 3 years ago.
the fix
propagate_unnamed_groups_to_included_urlconfs2.patch (2.6 KB) - added by stefantalpalaru 3 years ago.
better fix and test case

Download all attachments as: .zip

Change History (10)

Changed 3 years ago by rfugger

Changed 3 years ago by stefantalpalaru

the fix

comment:1 Changed 3 years ago by stefantalpalaru

  • Cc stefantalpalaru added
  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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

Changed 3 years ago by stefantalpalaru

better fix and test case

comment:2 Changed 3 years ago by stefantalpalaru

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

comment:3 Changed 3 years ago by eduardocereto

  • Cc eduardocereto@… added

comment:4 Changed 3 years ago by SmileyChris

  • Resolution set to wontfix
  • Status changed from new to closed
  • Type changed from Bug to New feature

This is not a bug -- the docs specifically cover the current behaviour:

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 Changed 3 years ago by rfugger

  • Resolution wontfix deleted
  • Status changed from closed to reopened
  • Type changed from New feature to 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:

  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:

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.


comment:6 Changed 2 years ago by aaugustin

  • Status changed from reopened to new

comment:7 Changed 8 months ago by timo

  • Has patch unset
Note: See TracTickets for help on using tickets.
Back to Top