Opened 16 years ago

Closed 16 years ago

Last modified 16 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: dev
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

reverse('django.contrib.admin.site.root')

The faulty code is get_callable inside urlresolvers.py.

Change History (4)

comment:1 by Eric Holscher, 16 years ago

milestone: 1.0
Triage Stage: UnreviewedDesign decision needed

comment:2 by James Bennett, 16 years ago

milestone: 1.0post-1.0

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

comment:3 by Malcolm Tredinnick, 16 years ago

Resolution: wontfix
Status: newclosed

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 by (none), 16 years ago

milestone: post-1.0

Milestone post-1.0 deleted

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