Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add django-debug-toolbar #575

Merged
merged 7 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
pass

# Application definition
INSTALLED_APPS = [
INSTALLED_APPS: list[str] = [
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
Expand All @@ -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",
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
19 changes: 17 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down