Opened 8 years ago

Closed 7 years ago

#6934 closed (fixed)

django.core.urlresolvers.reverse fails sometimes.

Reported by: sebastian_noack Owned by: mtredinnick
Component: Core (Other) Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:

Description (last modified by mtredinnick)

If you have a url pattern, containing...

  • nested groups
  • not-matching groups
  • look-ahead or look-behind groups

...django.core.urlresolvers.reverse will fail, because of following reasons:

  • To replace the groups re.sub with r'\(([^)]+)\)' is used, which matches only until the first ')', doesn't matter how much groups are nested.
  • All groups which are no named groups are assumed to be positional groups, regardless if they might be not-matching, look-ahead or look-behind groups.

Attachments (1)

support-for-more-flexible-url-regex-patterns.patch (2.6 KB) - added by sebastian_noack 8 years ago.

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by sebastian_noack

comment:1 Changed 8 years ago by mtredinnick

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to mtredinnick
  • Patch needs improvement set
  • Summary changed from [PATCH] django.core.urlresolvers.reverse fails sometimes. to django.core.urlresolvers.reverse fails sometimes.
  • Triage Stage changed from Unreviewed to Accepted

This is a dupe of #2977, amongst others. But I'll leave it open because the patch is an interesting approach. I really need to finish fixing this, so maybe this will get me motivated.

comment:2 Changed 8 years ago by sebastian_noack

  • Component changed from HTTP handling to Core framework

comment:3 Changed 8 years ago by sebastian_noack

This ticked is open and tagged as "Patch needs improvement" now over a month. Please can you tell me, what you don't like about my patch. So I can an acceptable patch for you. Thanks.

comment:4 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(In [8760]) A rewrite of the reverse URL parsing: the reverse() call and the "url" template tag.

This is fully backwards compatible, but it fixes a bunch of little bugs. Thanks
to SmileyChris and Ilya Semenov for some early patches in this area that were
incorporated into this change.

Fixed #2977, #4915, #6934, #7206.

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