From 2f24f473338d794768111ccaea37ba912a5ab53f Mon Sep 17 00:00:00 2001 From: Saqib Date: Fri, 11 Sep 2026 09:45:31 +0530 Subject: [PATCH] fix: register debug_toolbar in INSTALLED_APPS when DEBUG is on MIDDLEWARE conditionally added debug_toolbar's middleware when DEBUG is True, but INSTALLED_APPS never registered the app itself -- git history shows this pairing existed before and the INSTALLED_APPS half got dropped somewhere along this repo's messy merge/revert history. Broke every build since (confirmed via 3 failed CI runs today, all at the same step): the sanity-check step's `manage.py check` runs with DEBUG defaulting to True (no DEBUG env var set), and any request/check path that touches debug_toolbar's models crashes with "Model class debug_toolbar.models.HistoryEntry doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS" -- the middleware imports the app's models without the app being registered. --- DataSpace/settings.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/DataSpace/settings.py b/DataSpace/settings.py index 50a38dd..e1389d4 100644 --- a/DataSpace/settings.py +++ b/DataSpace/settings.py @@ -154,8 +154,12 @@ "api.middleware.logging.StructuredLoggingMiddleware", ] -# Add debug toolbar middleware if in debug mode +# Add debug toolbar app and middleware if in debug mode. Both are required -- +# the middleware alone crashes on any request/check that touches +# debug_toolbar's models: "HistoryEntry doesn't declare an explicit +# app_label and isn't in an application in INSTALLED_APPS". if DEBUG: + INSTALLED_APPS.append("debug_toolbar") MIDDLEWARE.insert(1, "debug_toolbar.middleware.DebugToolbarMiddleware") MIDDLEWARE += [