From 5e22ede54930363def1979ba6c56971998d38581 Mon Sep 17 00:00:00 2001 From: Steve Yonkeu Date: Sun, 18 Aug 2024 20:03:33 +0100 Subject: [PATCH] feat: adding debug toolbar --- config/docker/requirements.txt | 3 +-- website_api/routes/main.py | 2 ++ website_api/settings/extra.py | 13 ++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/config/docker/requirements.txt b/config/docker/requirements.txt index 0b67738..8aa6dba 100644 --- a/config/docker/requirements.txt +++ b/config/docker/requirements.txt @@ -1,9 +1,9 @@ beautifulsoup4==4.12.3 boto3==1.35.0 cfgv==3.4.0 -celery==5.4.0 django-cors-headers==4.3.1 django-crequest==2018.5.11 +django-debug-toolbar==4.4.6 django-dotenv==1.4.2 django-extensions==3.2.3 django-filter==23.5 @@ -18,7 +18,6 @@ nodeenv==1.8.0 pillow==10.3.0 psycopg2-binary==2.9.9 python-dotenv==1.0.0 -redis==5.0.8 tzdata==2023.4 virtualenv==20.25.0 whitenoise==6.7.0 diff --git a/website_api/routes/main.py b/website_api/routes/main.py index d777691..7692c1f 100644 --- a/website_api/routes/main.py +++ b/website_api/routes/main.py @@ -1,3 +1,4 @@ +import debug_toolbar from django.conf import settings from django.conf.urls.static import static from django.contrib import admin @@ -10,6 +11,7 @@ urlpatterns = ( [ path("admin/", admin.site.urls), + path('__debug__/', include(debug_toolbar.urls)), path(f"{BASE_API_URL}/", include("apps.users.routes.api")), path(f"{BASE_API_URL}/", include("apps.events.routes.api")), path(f"{BASE_API_URL}/", include("apps.events.routes.extra")), diff --git a/website_api/settings/extra.py b/website_api/settings/extra.py index ca54034..f613f22 100644 --- a/website_api/settings/extra.py +++ b/website_api/settings/extra.py @@ -1,7 +1,7 @@ import os from utils.main import load_documentation -from .base import BASE_DIR, TIME_ZONE +from .base import BASE_DIR, TIME_ZONE, INSTALLED_APPS, MIDDLEWARE REST_FRAMEWORK = { "EXCEPTION_HANDLER": "exceptions.rest_exception.rest_exception_handler", @@ -106,3 +106,14 @@ CELERY_RESULT_BACKEND = os.getenv('CELERY_RESULT_BACKEND') CELERY_TIMEZONE = TIME_ZONE CELERY_BROKER_CONNECTION_RETRY_ON_STARTUP = True + +# Django Debug ToolBar settings +if os.getenv("ENVIRONMENT") == "development": + INSTALLED_APPS += ['debug_toolbar'] + MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware'] + DEBUG_TOOLBAR_CONFIG = { + 'SHOW_TOOLBAR_CALLBACK': lambda request: True, + } + INTERNAL_IPS = [ + '127.0.0.1', + ]