fix(debug-toolbar): Hide debug toolbar on API documentation pages

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 <noreply@anthropic.com>
This commit is contained in:
poduck
2025-12-01 03:59:40 -05:00
parent f16ccf76a8
commit 10afe61bb8

View File

@@ -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"]