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