Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#7879 closed (wontfix)

reverse/url tag assumes view is a module-level callable

Reported by: miracle2k Owned by: nobody
Component: Core (Other) Version: master
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


django.core.urlresolvers.reverse, when called with a string argument, requires that string to reference a view inside a module, which means that the following won't work, since site is a class, and admin is the module.


The faulty code is get_callable inside

Change History (4)

comment:1 Changed 7 years ago by ericholscher

  • milestone set to 1.0
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 7 years ago by ubernostrum

  • milestone changed from 1.0 to post-1.0

Reversing stuff in AdminSite is a much larger problem that needs to be dealt with later on.

comment:3 Changed 7 years ago by mtredinnick

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

This is really fiddly to handle all the cases, since it requires stepping through one dotted piece at a time checking if it's something to import or a class or whatever. Since reverse-resolving is already slow to start up as it is, it's not really worth it.

The correct thing to do here is to use the named URL-pattern form:

url(r'^admin/(.*)', admin.sites.root, name='my-admin-root'),

and then {% url my-admin-root "" %} will do work as you expect.

It's arguably a bug that the empty string is needed if you only want the root, but that's an issue with reverse() and I've opened #9239 for that.

comment:4 Changed 7 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

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