From 10afe61bb86db563d3dbd92e9d49e7275f250a5b Mon Sep 17 00:00:00 2001 From: poduck Date: Mon, 1 Dec 2025 03:59:40 -0500 Subject: [PATCH] fix(debug-toolbar): Hide debug toolbar on API documentation pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added SHOW_TOOLBAR_CALLBACK to exclude the debug toolbar from displaying on /v1/* paths (Swagger UI and ReDoc documentation). This prevents the large debug toolbar logo from interfering with the API documentation interface. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- smoothschedule/config/settings/local.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/smoothschedule/config/settings/local.py b/smoothschedule/config/settings/local.py index ab50089..eaaad22 100644 --- a/smoothschedule/config/settings/local.py +++ b/smoothschedule/config/settings/local.py @@ -95,6 +95,16 @@ INSTALLED_APPS += ["debug_toolbar"] # https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#middleware MIDDLEWARE += ["debug_toolbar.middleware.DebugToolbarMiddleware"] # https://django-debug-toolbar.readthedocs.io/en/latest/configuration.html#debug-toolbar-config + + +def show_toolbar(request): + """Hide debug toolbar on API documentation pages.""" + # Hide on Swagger/ReDoc API documentation + if request.path.startswith("/v1/"): + return False + return True + + DEBUG_TOOLBAR_CONFIG = { "DISABLE_PANELS": [ "debug_toolbar.panels.redirects.RedirectsPanel", @@ -103,6 +113,7 @@ DEBUG_TOOLBAR_CONFIG = { "debug_toolbar.panels.profiling.ProfilingPanel", ], "SHOW_TEMPLATE_CONTEXT": True, + "SHOW_TOOLBAR_CALLBACK": show_toolbar, } # https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#internal-ips INTERNAL_IPS = ["127.0.0.1", "10.0.2.2"]