From 9301f295cc319a0c03663e41d13ddadfed43e7d3 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 24 May 2024 21:41:53 +0100 Subject: [PATCH] Opt-in to DDT --- yamdl_playground/settings.py | 9 ++++++--- yamdl_playground/urls.py | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/yamdl_playground/settings.py b/yamdl_playground/settings.py index 3a12eaa..f4c4e06 100644 --- a/yamdl_playground/settings.py +++ b/yamdl_playground/settings.py @@ -34,14 +34,12 @@ ALLOWED_HOSTS = ["*"] INSTALLED_APPS = [ 'django.contrib.staticfiles', "yamdl_playground.core", - "yamdl", - "debug_toolbar" + "yamdl" ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.middleware.common.CommonMiddleware', - "debug_toolbar.middleware.DebugToolbarMiddleware", 'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] @@ -214,3 +212,8 @@ if "ENABLE_ADMIN" in os.environ: 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ]) + + +if "ENABLE_DDT" in os.environ: + INSTALLED_APPS.append("debug_toolbar") + MIDDLEWARE.append("debug_toolbar.middleware.DebugToolbarMiddleware") diff --git a/yamdl_playground/urls.py b/yamdl_playground/urls.py index 2d12acc..fee228a 100644 --- a/yamdl_playground/urls.py +++ b/yamdl_playground/urls.py @@ -21,7 +21,6 @@ from django.apps import apps urlpatterns = [ path("search/", views.search), path("content//", views.content), - path("__debug__/", include("debug_toolbar.urls")), path("cached-content//", views.cached_content) ] @@ -29,3 +28,6 @@ if apps.is_installed("django.contrib.admin"): from django.contrib import admin urlpatterns.append(path("admin/", admin.site.urls)) + +if apps.is_installed("debug_toolbar"): + urlpatterns.append(path("__debug__/", include("debug_toolbar.urls")))