Ensure that toolbar templates get the injected urlconf. #254

Closed
wants to merge 2 commits into
from

Projects

None yet

5 participants

crass commented Jan 16, 2012

This change allows one to use django-debug-toolbar-user-panel without needing to modify the root urlconf. Django resets the default urlconf before the response middleware is run, so there is no default urlconf for reverse to lookup view names in. This is normally fine, but django-debug-toolbar does some template rendering in the response middleware. Also, with this change django-debug-toolbar may now use {% url viewname %} instead of hardcoded url paths.

Owner
jezdez commented Apr 7, 2012

Wait, why do you use set_urlconf(None) on the way out though? Wouldn't that reset any custom URLconf set outside of the toolbar?

@aaugustin aaugustin referenced this pull request in ionelmc/django-debug-toolbar Oct 22, 2013
@ionelmc ionelmc Reverse the urls in the panels (it cannot be done in the templates be…
…cause of custom urlconf).
abc2503
Contributor

As of version 1.6, Django no longer resets the urlconf.

See django/django@521765f.

Contributor

I'm wondering if monkey-patching the URLconf doesn't create more trouble that it's worth :/

It was introduced in a77ee9c. The commit message is interesting (cc @jacobian).

Since then there've been efforts to maintain the hack. It has extended from 5 to 18 lines of code, and is the root cause of several issues filed on this tracker.

Contributor

I'm not sure I even intended that to be a final solution; it was just something that worked.

ionelmc commented Oct 26, 2013

I don't think anyone would mind having an extra entry in their urls conf. The views would need to be disabled (eg, return 501 or something) if the toolbar is not active.

Contributor

I believe this was fixed in #456. Let me know if I missed something.

@aaugustin aaugustin closed this Nov 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment