diff --git a/core/settings.py b/core/settings.py index 7b40610e..2cbd433d 100644 --- a/core/settings.py +++ b/core/settings.py @@ -32,7 +32,7 @@ pass # Application definition -INSTALLED_APPS = [ +INSTALLED_APPS: list[str] = [ "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", @@ -46,10 +46,14 @@ "waffle", ] +INTERNAL_IPS: list[str] = [ + "127.0.0.1", +] + if os.environ.get("AZURE_AUTH_ENABLED", "true") != "false": INSTALLED_APPS.append("azure_auth") -MIDDLEWARE = [ +MIDDLEWARE: list[str] = [ "django_prometheus.middleware.PrometheusBeforeMiddleware", "django.middleware.security.SecurityMiddleware", "whitenoise.middleware.WhiteNoiseMiddleware", @@ -224,6 +228,11 @@ environment=ENV or "local", ) +# add debug toolbar when not running tests +if DEBUG and not TESTING: + INSTALLED_APPS.insert(-1, "debug_toolbar") + MIDDLEWARE.insert(1, "debug_toolbar.middleware.DebugToolbarMiddleware") + # Enable / Disable Azure Auth if not os.environ.get("AZURE_AUTH_ENABLED", "true") == "false": # Adds the Azure Authentication middleware to the Django Authentication middleware diff --git a/core/urls.py b/core/urls.py index aa8d8f85..e6d07e0c 100644 --- a/core/urls.py +++ b/core/urls.py @@ -15,6 +15,8 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ +from debug_toolbar.toolbar import debug_toolbar_urls +from django.conf import settings from django.urls import include, path app_name = "core" @@ -26,4 +28,9 @@ path("", include("django_prometheus.urls")), ] +if settings.DEBUG and not settings.TESTING: + urlpatterns = [ + *urlpatterns, + ] + debug_toolbar_urls() + handler404 = "core.views.handler404" diff --git a/poetry.lock b/poetry.lock index 2094e86d..59952e79 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "acryl-datahub" @@ -820,6 +820,21 @@ files = [ Django = ">=3.2" msal = ">=1.18.0,<2.0.0" +[[package]] +name = "django-debug-toolbar" +version = "4.4.6" +description = "A configurable set of panels that display various debug information about the current request/response." +optional = false +python-versions = ">=3.8" +files = [ + {file = "django_debug_toolbar-4.4.6-py3-none-any.whl", hash = "sha256:3beb671c9ec44ffb817fad2780667f172bd1c067dbcabad6268ce39a81335f45"}, + {file = "django_debug_toolbar-4.4.6.tar.gz", hash = "sha256:36e421cb908c2f0675e07f9f41e3d1d8618dc386392ec82d23bcfcd5d29c7044"}, +] + +[package.dependencies] +django = ">=4.2.9" +sqlparse = ">=0.2" + [[package]] name = "django-prometheus" version = "2.3.1" @@ -3119,4 +3134,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "c8463d9a43a531980200f1dfe575fdb652b0232c2717eb56a33915d802ff3b75" +content-hash = "988e6fc1908a22e27a042eb5d6c4f8294d6c70007bbc0c65db3f2948265460fe" diff --git a/pyproject.toml b/pyproject.toml index dd1fb6ef..ac578761 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,7 @@ django-azure-auth = "2.0.2" django-waffle = "^4.1.0" psycopg = "^3.2.1" psycopg-binary = "^3.2.1" +django-debug-toolbar = "^4.4.6" redis = {extras = ["hiredis"], version = "^5.0.8"} [tool.poetry.group.dev.dependencies]