From b48382e990b80fcba9c9e2d611793c8ed5b4ef88 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 15 Dec 2025 21:44:57 +0000 Subject: [PATCH] . --- djangorota/djangorota/settings.py | 11 +++++++++++ djangorota/djangorota/urls.py | 10 ++++++++++ requirements.txt | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/djangorota/djangorota/settings.py b/djangorota/djangorota/settings.py index 0e403a5..68a2f3b 100644 --- a/djangorota/djangorota/settings.py +++ b/djangorota/djangorota/settings.py @@ -43,10 +43,14 @@ INSTALLED_APPS += [ "rota", "crispy_forms", "crispy_bulma", + # Debug toolbar for local development + "debug_toolbar", ] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", + # Debug toolbar middleware should run as early as possible + "debug_toolbar.middleware.DebugToolbarMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", @@ -133,6 +137,13 @@ STATICFILES_DIRS = [ BASE_DIR.parent / "static", ] +# django-debug-toolbar settings (development only) +INTERNAL_IPS = ["127.0.0.1", "::1"] +# Simple debug toolbar config: show when DEBUG is True and request comes from INTERNAL_IPS +DEBUG_TOOLBAR_CONFIG = { + "SHOW_TOOLBAR_CALLBACK": lambda request: DEBUG, +} + # Default primary key field type DEFAULT_AUTO_FIELD = "django.db.models.AutoField" diff --git a/djangorota/djangorota/urls.py b/djangorota/djangorota/urls.py index 995fa30..75fa113 100644 --- a/djangorota/djangorota/urls.py +++ b/djangorota/djangorota/urls.py @@ -17,8 +17,18 @@ Including another URLconf from django.contrib import admin from django.urls import path, include +from django.conf import settings urlpatterns = [ path("admin/", admin.site.urls), path("", include(("rota.urls", "rota"), namespace="rota")), ] + +if settings.DEBUG: + try: + import debug_toolbar + + urlpatterns = [path("__debug__/,", include(debug_toolbar.urls))] + urlpatterns + except Exception: + # debug_toolbar not installed; skip + pass diff --git a/requirements.txt b/requirements.txt index 3156109..b80a844 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,4 +17,5 @@ highspy typer django>=6.0,<7 django-crispy-forms -crispy-bulma \ No newline at end of file +crispy-bulma +django-debug-toolbar \ No newline at end of file