From 0f9311d62f6d54926dc4193b41f2c5fd706e0e3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Seppo=20=C3=84yr=C3=A4v=C3=A4inen?= Date: Wed, 12 Nov 2025 13:39:45 +0200 Subject: [PATCH] Use django-debug-toolbar 6.1 or later for better support of debugging with Docker --- aplus/settings.py | 12 +++++------- requirements_testing.txt | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/aplus/settings.py b/aplus/settings.py index c51b147dd..470de96b2 100644 --- a/aplus/settings.py +++ b/aplus/settings.py @@ -616,10 +616,8 @@ INTERNAL_IPS.append('127.0.0.1') except NameError: INTERNAL_IPS = ['127.0.0.1'] - try: - # pylint: disable-next=used-before-assignment - DEBUG_TOOLBAR_CONFIG.setdefault('SHOW_TOOLBAR_CONFIG', 'lib.helpers.show_debug_toolbar') - except NameError: - DEBUG_TOOLBAR_CONFIG = { - 'SHOW_TOOLBAR_CALLBACK': 'lib.helpers.show_debug_toolbar', - } + # Configure Debug Toolbar to work under Docker by auto-detecting the gateway IP + # See: https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#docker + DEBUG_TOOLBAR_CONFIG = globals().get('DEBUG_TOOLBAR_CONFIG', {}) + # Always use the Docker-aware callback so toolbar shows when accessed via localhost + DEBUG_TOOLBAR_CONFIG.setdefault('SHOW_TOOLBAR_CALLBACK', 'debug_toolbar.middleware.show_toolbar_with_docker') diff --git a/requirements_testing.txt b/requirements_testing.txt index 99140b17e..14b9d47c0 100644 --- a/requirements_testing.txt +++ b/requirements_testing.txt @@ -3,7 +3,7 @@ coverage # Required to run browser tests: selenium pyvirtualdisplay -django-debug-toolbar >= 3.2.2, < 4 +django-debug-toolbar >= 6.1.0, < 7 prospector pytest-playwright pytest-django