New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filtering by requested URL #284
Comments
I stepped into the same issue and agree with gw0 on suggesting an implementation of common filtering patterns to quickly remove the toolbar from matching urls. Just an hint. Either way, really good job the all-mighty debug-toolbar. You guys rock! |
Now that #324 is fixed, this has become really simple to implement. Here's how you would exclude the admin:
Here's how you would exclude a series of URL prefixes:
I don't think it would be easier to use a DSL for filtering URLs. Plain Python is a suitable tool for this class of problems. Thanks for the suggestion anyway! |
For anyone else landing here, it seems that the def custom_show_toolbar(request):
from debug_toolbar.middleware import show_toolbar
return show_toolbar(request) and not request.path.startswith("/graphql")
DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": custom_show_toolbar} |
I know that with the callback function one can implement his own complex mechanism of deciding when to display the Django Debug Toolbar and when not, but common filtering use cases (like checking users IP) should be made as simple as possible.
Therefore I suggest an configuration option to filter out (not show) the toolbar on pages whose URLs match a specific pattern (or regular expression). E.g. if you are using the Django admin panel, but not developing enything in it, you do not need the debug toolbar there, so it would be nice to filter out the toolbar on all requests under
'^admin/'
. Same need appears if you have a page with many small iframes and you just want to debug the outside Django app and templates, not the ones in the small iframes - here it would be nice to hide the toolbar on all requests to the iframed app.Suggestion is therefore to have one or more regular expressions for filtering where the toolbar should be shown based on the requested URL. E.g. either as a complex regex or as a list of simpler regexes:
The text was updated successfully, but these errors were encountered: