Opened 7 years ago

Closed 4 years ago

#15723 closed Cleanup/optimization (needsinfo)

Document limitations of reverse

Reported by: zeroos Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords: reverse regexp
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


In I have the following line:

(r'^json/calendar/((?P<course>[\d,]+)/)?$', json.calendar_block),

When I try to reverse this url this way:

reverse(json.calendar_block, kwargs={'course': 1})

I get an error saying that it cannot reverse this.

When I change the line in to:

(r'^json/calendar/(?P<course>[\d,]+)/$', json.calendar_block),

everything works great.

I would assume that it is not a bug, but it worked before and suddenly, after pulling the newest Django release from svn it stopped.

Change History (7)

comment:1 Changed 7 years ago by Luke Plant

Type: Bug

comment:2 Changed 7 years ago by Luke Plant

Severity: Normal

comment:3 Changed 7 years ago by Julien Phalip

Component: Core (Other)Documentation
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

The reverse() function does have some limitations, as stated in the doc ( "The reverse() function can reverse a large variety of regular expression patterns for URLs, but not every possible one". I think this is the case here. The documentation can be improved though, to reflect all (or at least the most common) limitations.

comment:4 Changed 6 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 Changed 6 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:6 Changed 6 years ago by Tim Graham

Summary: reverse does not work if quotation mark is used on a keyword argumentDocument limitations of reverse

I am not sure what to add here as far as docs go. The code for reverse doesn't look too simple to me, and I am not sure how much detail we want to go into about how it works. Maybe the fact that nested groupings aren't supported? I haven't confirmed that to be the case, it's just a guess based on the example that doesn't work.

comment:7 Changed 4 years ago by Tim Graham

Resolution: needsinfo
Status: newclosed

In the doc we have: "The main restriction at the moment is that the pattern cannot contain alternative choices using the vertical bar ("|") character." I am closing this as needsinfo. If someone wants to do research and propose a patch, then please reopen with details.

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