From 8e5f976fdd3f3553a80fbe2ded2751dee7aa13d0 Mon Sep 17 00:00:00 2001 From: superolegatron Date: Tue, 3 Sep 2024 17:39:36 +0300 Subject: [PATCH 1/3] for now swagger and debug_toolbar are reachable only in development, when DEBUG is True --- BackEnd/forum/urls.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/BackEnd/forum/urls.py b/BackEnd/forum/urls.py index 4da1b3af6..30fe278a3 100644 --- a/BackEnd/forum/urls.py +++ b/BackEnd/forum/urls.py @@ -29,13 +29,17 @@ ), path("api/", include("search.urls", namespace="search")), path("api/", include("images.urls", namespace="images")), - path("api/schema/", SpectacularAPIView.as_view(), name="schema"), - path( - "api/schema/docs/", - SpectacularSwaggerView.as_view(url_name="schema"), - name="schema_docs", - ), - path("__debug__/", include("debug_toolbar.urls")), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urlpatterns += staticfiles_urlpatterns() + +if settings.DEBUG: + urlpatterns += [ + path("api/schema/", SpectacularAPIView.as_view(), name="schema"), + path( + "api/schema/docs/", + SpectacularSwaggerView.as_view(url_name="schema"), + name="schema_docs", + ), + path("__debug__/", include("debug_toolbar.urls")), + ] From 307ee4e60521d04f2ed96c8459d48cc17e84005b Mon Sep 17 00:00:00 2001 From: superolegatron Date: Tue, 3 Sep 2024 18:03:29 +0300 Subject: [PATCH 2/3] Bug fix --- BackEnd/forum/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BackEnd/forum/urls.py b/BackEnd/forum/urls.py index 30fe278a3..a0273d47e 100644 --- a/BackEnd/forum/urls.py +++ b/BackEnd/forum/urls.py @@ -29,6 +29,7 @@ ), path("api/", include("search.urls", namespace="search")), path("api/", include("images.urls", namespace="images")), + path("__debug__/", include("debug_toolbar.urls")), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urlpatterns += staticfiles_urlpatterns() @@ -41,5 +42,4 @@ SpectacularSwaggerView.as_view(url_name="schema"), name="schema_docs", ), - path("__debug__/", include("debug_toolbar.urls")), ] From ef38ab78fd475c85a9267272cfa213bc171512fb Mon Sep 17 00:00:00 2001 From: superolegatron Date: Wed, 4 Sep 2024 00:22:58 +0300 Subject: [PATCH 3/3] minor fixes --- BackEnd/forum/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BackEnd/forum/settings.py b/BackEnd/forum/settings.py index 2755a889b..77369e081 100644 --- a/BackEnd/forum/settings.py +++ b/BackEnd/forum/settings.py @@ -27,7 +27,7 @@ SECRET_KEY = config("SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = config("DEBUG") +DEBUG = config("DEBUG", cast=bool) ALLOWED_HOSTS = [ "localhost",