Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Allow disabling on a per-view basis via decorator #554

v4eddie opened this Issue Feb 28, 2014 · 2 comments


None yet
2 participants

v4eddie commented Feb 28, 2014

A very handy feature for me would be a clean way to selectively disable (or enable) the toolbar on a per-view basis. The show_toolbar callback gets called during the process_request phase of the Middleware, which means URL resolution has not occurred and the view function is not yet known. I understand this is necessary to allow the panels to do processing at that point, but it would be very useful to be able to "short-circuit" the toolbar processing at the process_view phase.

Perhaps check for an attribute on the view function itself. Then a very simple decorator function could be written that sets that attribute.

As it is, I end up duplicating a lot of the URL parsing in my show_toolbar function if I want this functionality.

I do have a hacked-up version of a no_toolbar decorator that manually sets the per-thread toolbar object to None (I won't put the code here because I fear it's too fragile, and I wouldn't want someone to copy-paste it blindly).


aaugustin commented Mar 9, 2014

Your solution works but it would probably be easier to subclass DebugToolbarMiddleware and override process_view.

I'm not convinced it's worth adding an API for this purpose. Subclassing is an appropriate workaround for your use case.

Thanks for your report anyway. I may reconsider this decision if other users want that too.

@aaugustin aaugustin closed this Mar 9, 2014

v4eddie commented Mar 10, 2014

Thanks for the reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment