From f2127e563063ba11bc52d25f9c97b98e8881973c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20H=C3=A1la?= Date: Fri, 20 Dec 2024 14:48:25 +0100 Subject: [PATCH] Add Media urls and debug toolbar only when Debug=true --- chords/urls.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/chords/urls.py b/chords/urls.py index 4b9a4d1..043938a 100644 --- a/chords/urls.py +++ b/chords/urls.py @@ -14,7 +14,6 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ -import debug_toolbar from django.conf import settings from django.conf.urls.static import static from django.contrib import admin @@ -30,5 +29,12 @@ path("tenants/", include(("tenants.urls", "tenants"), namespace="tenants")), re_path(r"^", include(("backend.urls", "backend"), namespace="chords")), path("admin/", admin.site.urls), - path("__debug__/", include(debug_toolbar.urls)), -] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) +] + +if settings.DEBUG: + import debug_toolbar + + urlpatterns += [ + path("__debug__/", include(debug_toolbar.urls)), + *static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT), + ]