From 7578645a4a8d3a2efb0976fbe12b7002340eda86 Mon Sep 17 00:00:00 2001 From: Johanan Oppong Amoateng Date: Sun, 12 Oct 2025 15:56:04 +0000 Subject: [PATCH 1/5] Deprecate RedirectsPanel and update tests for deprecation warning --- debug_toolbar/panels/redirects.py | 12 ++++++++++++ docs/changes.rst | 2 ++ docs/panels.rst | 7 +++++++ tests/panels/test_redirects.py | 18 ++++++++++++++++++ 4 files changed, 39 insertions(+) diff --git a/debug_toolbar/panels/redirects.py b/debug_toolbar/panels/redirects.py index 8055c67ad..1db439723 100644 --- a/debug_toolbar/panels/redirects.py +++ b/debug_toolbar/panels/redirects.py @@ -1,3 +1,4 @@ +import warnings from inspect import iscoroutine from django.template.response import SimpleTemplateResponse @@ -17,6 +18,17 @@ class RedirectsPanel(Panel): nav_title = _("Intercept redirects") + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + warnings.warn( + "The RedirectsPanel is deprecated and will be removed in a future version. " + "The HistoryPanel now provides the ability to view toolbar data for redirected requests. " + "If you still have a use case for this panel, please comment on " + "https://github.com/django-commons/django-debug-toolbar/issues/2216", + DeprecationWarning, + stacklevel=2, + ) + def _process_response(self, response): """ Common response processing logic. diff --git a/docs/changes.rst b/docs/changes.rst index aac1e6031..3718b04d4 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -15,6 +15,8 @@ Pending * Added ``CommunityPanel`` containing links to documentation and resources. * Added how to generate the documentation locally to the contributing documentation. +* Deprecated ``RedirectsPanel`` in favor of ``HistoryPanel`` for viewing + toolbar data from redirected requests. 6.0.0 (2025-07-22) ------------------ diff --git a/docs/panels.rst b/docs/panels.rst index f2364ea7c..5f1b37b4f 100644 --- a/docs/panels.rst +++ b/docs/panels.rst @@ -120,6 +120,13 @@ Redirects .. class:: debug_toolbar.panels.redirects.RedirectsPanel +.. deprecated:: 6.0 + +The RedirectsPanel is deprecated and will be removed in a future version. +The HistoryPanel now provides the ability to view toolbar data for redirected +requests. If you have a use case for this panel, please comment on the +GitHub issue `_. + When this panel is enabled, the debug toolbar will show an intermediate page upon redirect so you can view any debug information prior to redirecting. This page will provide a link to the redirect destination you can follow when diff --git a/tests/panels/test_redirects.py b/tests/panels/test_redirects.py index c81c7eaba..fc7b64d7b 100644 --- a/tests/panels/test_redirects.py +++ b/tests/panels/test_redirects.py @@ -1,4 +1,5 @@ import copy +import warnings from django.conf import settings from django.http import HttpResponse @@ -12,6 +13,12 @@ class RedirectsPanelTestCase(BaseTestCase): panel_id = RedirectsPanel.panel_id + def setUp(self): + # Suppress the deprecation warning during setup + with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + super().setUp() + def test_regular_response(self): not_redirect = HttpResponse() self._get_response = lambda request: not_redirect @@ -100,3 +107,14 @@ def test_original_response_preserved(self): self.assertEqual( response.original_response.get("Location"), "http://somewhere/else/" ) + + def test_deprecation_warning(self): + """Test that a deprecation warning is shown when RedirectsPanel is instantiated.""" + from debug_toolbar.toolbar import DebugToolbar + + with self.assertWarns(DeprecationWarning) as cm: + toolbar = DebugToolbar(self.request, self._get_response) + toolbar.get_panel_by_id(RedirectsPanel.panel_id) + + self.assertIn("RedirectsPanel is deprecated", str(cm.warning)) + self.assertIn("HistoryPanel", str(cm.warning)) From d713a499fe6136e3a50c425284214ee9fcb1cdc2 Mon Sep 17 00:00:00 2001 From: Johanan Oppong Amoateng Date: Mon, 13 Oct 2025 15:30:33 +0000 Subject: [PATCH 2/5] fix: reorganize import --- tests/panels/test_redirects.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/panels/test_redirects.py b/tests/panels/test_redirects.py index fc7b64d7b..86622b157 100644 --- a/tests/panels/test_redirects.py +++ b/tests/panels/test_redirects.py @@ -6,6 +6,7 @@ from django.test import AsyncRequestFactory from debug_toolbar.panels.redirects import RedirectsPanel +from debug_toolbar.toolbar import DebugToolbar from ..base import BaseTestCase @@ -110,7 +111,6 @@ def test_original_response_preserved(self): def test_deprecation_warning(self): """Test that a deprecation warning is shown when RedirectsPanel is instantiated.""" - from debug_toolbar.toolbar import DebugToolbar with self.assertWarns(DeprecationWarning) as cm: toolbar = DebugToolbar(self.request, self._get_response) From 1b1c14c0df9aee9678e81ddc7cf9f8b5df393e44 Mon Sep 17 00:00:00 2001 From: Johanan Oppong Amoateng Date: Tue, 14 Oct 2025 09:28:17 +0000 Subject: [PATCH 3/5] feat: add deprecation warning for RedirectsPanel in redirect template and style it --- .../static/debug_toolbar/css/toolbar.css | 49 +++++++++++++++++++ .../templates/debug_toolbar/redirect.html | 4 ++ 2 files changed, 53 insertions(+) diff --git a/debug_toolbar/static/debug_toolbar/css/toolbar.css b/debug_toolbar/static/debug_toolbar/css/toolbar.css index 120b8958c..b5222e077 100644 --- a/debug_toolbar/static/debug_toolbar/css/toolbar.css +++ b/debug_toolbar/static/debug_toolbar/css/toolbar.css @@ -1219,3 +1219,52 @@ To regenerate: #djDebug .djdt-community-panel a:hover { text-decoration: underline; } + +.deprecation-warning { + position: relative; + background-color: #fffbdb; + color: #735c0f; + border-left: 4px solid #f1c40f; + padding: 16px 45px 16px 16px; + margin: 20px 0; + border-radius: 3px; + box-shadow: + 0 1px 3px rgba(0, 0, 0, 0.12), + 0 1px 2px rgba(0, 0, 0, 0.24); + font-family: var(--djdt-font-family-primary); + font-size: 14px; + line-height: 1.5; +} + +.deprecation-warning::before { + content: "⚠️"; + font-size: 18px; + margin-right: 12px; + vertical-align: middle; +} + +.deprecation-warning a { + color: #1a5fb4; + text-decoration: none; + font-weight: 500; + border-bottom: 1px solid #1a5fb4; + padding-bottom: 1px; + transition: all 0.2s ease; +} + +.deprecation-warning a:hover { + color: #0d47a1; + border-bottom: 2px solid #0d47a1; +} + +.deprecation-warning strong { + color: #000; + font-weight: 600; +} + +@media (max-width: 768px) { + .deprecation-warning { + padding: 12px 12px 12px 12px; + margin: 15px 0; + } +} diff --git a/debug_toolbar/templates/debug_toolbar/redirect.html b/debug_toolbar/templates/debug_toolbar/redirect.html index 46897846d..07b5c7487 100644 --- a/debug_toolbar/templates/debug_toolbar/redirect.html +++ b/debug_toolbar/templates/debug_toolbar/redirect.html @@ -4,8 +4,12 @@ Django Debug Toolbar Redirects Panel: {{ status_line }} + +
+ {% translate "WARNING:" %} {% translate "The RedirectsPanel is deprecated and will be removed in a future version. The HistoryPanel now provides the ability to view toolbar data for redirected requests. If you still have a use case for this panel, please comment on this issue" %} +

{{ status_line }}

{% translate "Location:" %} {{ redirect_to }}

From 000e1810a2fb2a2d529caa3af24e8374aa78d6b9 Mon Sep 17 00:00:00 2001 From: Johanan Oppong Amoateng Date: Sat, 18 Oct 2025 11:36:08 +0000 Subject: [PATCH 4/5] feat: update deprecation warning styling and structure in RedirectsPanel template --- .../static/debug_toolbar/css/toolbar.css | 59 ++++++++++--------- .../templates/debug_toolbar/redirect.html | 4 +- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/debug_toolbar/static/debug_toolbar/css/toolbar.css b/debug_toolbar/static/debug_toolbar/css/toolbar.css index b5222e077..88154ba4a 100644 --- a/debug_toolbar/static/debug_toolbar/css/toolbar.css +++ b/debug_toolbar/static/debug_toolbar/css/toolbar.css @@ -1220,51 +1220,52 @@ To regenerate: text-decoration: underline; } -.deprecation-warning { +#djDebug .djdt-deprecation-warning { + --djdt-warning-bg: #fff3cd; + --djdt-warning-text: #856404; + --djdt-warning-accent: #f1c40f; + --djdt-warning-link: #0056b3; + --djdt-warning-link-hover: #003d7a; + --djdt-warning-strong: #000; + --djdt-warning-shadow: rgba(0, 0, 0, 0.1); + position: relative; - background-color: #fffbdb; - color: #735c0f; - border-left: 4px solid #f1c40f; - padding: 16px 45px 16px 16px; - margin: 20px 0; - border-radius: 3px; + background-color: var(--djdt-warning-bg); + color: var(--djdt-warning-text); + border-left: 0.25em solid var(--djdt-warning-accent); + padding: 1em; + margin: 1.5em 0; + border-radius: 0.25em; box-shadow: - 0 1px 3px rgba(0, 0, 0, 0.12), - 0 1px 2px rgba(0, 0, 0, 0.24); + 0 0.0625em 0.1875em var(--djdt-warning-shadow), + 0 0.0625em 0.125em var(--djdt-warning-shadow); font-family: var(--djdt-font-family-primary); - font-size: 14px; + font-size: 0.875em; line-height: 1.5; } -.deprecation-warning::before { +#djDebug .djdt-deprecation-warning::before { content: "⚠️"; - font-size: 18px; - margin-right: 12px; + font-size: 1.125em; + margin-right: 0.75em; vertical-align: middle; } -.deprecation-warning a { - color: #1a5fb4; +#djDebug .djdt-deprecation-warning a { + color: var(--djdt-warning-link); text-decoration: none; font-weight: 500; - border-bottom: 1px solid #1a5fb4; - padding-bottom: 1px; + border-bottom: 0.0625em solid currentColor; + padding-bottom: 0.0625em; transition: all 0.2s ease; } -.deprecation-warning a:hover { - color: #0d47a1; - border-bottom: 2px solid #0d47a1; +#djDebug .djdt-deprecation-warning a:hover { + color: var(--djdt-warning-link-hover); + border-bottom-width: 0.125em; } -.deprecation-warning strong { - color: #000; +#djDebug .djdt-deprecation-warning strong { + color: var(--djdt-warning-strong); font-weight: 600; } - -@media (max-width: 768px) { - .deprecation-warning { - padding: 12px 12px 12px 12px; - margin: 15px 0; - } -} diff --git a/debug_toolbar/templates/debug_toolbar/redirect.html b/debug_toolbar/templates/debug_toolbar/redirect.html index 07b5c7487..169113aae 100644 --- a/debug_toolbar/templates/debug_toolbar/redirect.html +++ b/debug_toolbar/templates/debug_toolbar/redirect.html @@ -6,8 +6,8 @@ - -

+ +
{% translate "WARNING:" %} {% translate "The RedirectsPanel is deprecated and will be removed in a future version. The HistoryPanel now provides the ability to view toolbar data for redirected requests. If you still have a use case for this panel, please comment on this issue" %}

{{ status_line }}

From c5a4876478fb2a4664c4e481d135e851391aa024 Mon Sep 17 00:00:00 2001 From: Johanan Oppong Amoateng Date: Fri, 24 Oct 2025 22:55:04 +0000 Subject: [PATCH 5/5] switch to blocktranslate and move styling into template --- .../static/debug_toolbar/css/toolbar.css | 50 --------------- .../templates/debug_toolbar/redirect.html | 63 ++++++++++++++++++- 2 files changed, 61 insertions(+), 52 deletions(-) diff --git a/debug_toolbar/static/debug_toolbar/css/toolbar.css b/debug_toolbar/static/debug_toolbar/css/toolbar.css index 88154ba4a..120b8958c 100644 --- a/debug_toolbar/static/debug_toolbar/css/toolbar.css +++ b/debug_toolbar/static/debug_toolbar/css/toolbar.css @@ -1219,53 +1219,3 @@ To regenerate: #djDebug .djdt-community-panel a:hover { text-decoration: underline; } - -#djDebug .djdt-deprecation-warning { - --djdt-warning-bg: #fff3cd; - --djdt-warning-text: #856404; - --djdt-warning-accent: #f1c40f; - --djdt-warning-link: #0056b3; - --djdt-warning-link-hover: #003d7a; - --djdt-warning-strong: #000; - --djdt-warning-shadow: rgba(0, 0, 0, 0.1); - - position: relative; - background-color: var(--djdt-warning-bg); - color: var(--djdt-warning-text); - border-left: 0.25em solid var(--djdt-warning-accent); - padding: 1em; - margin: 1.5em 0; - border-radius: 0.25em; - box-shadow: - 0 0.0625em 0.1875em var(--djdt-warning-shadow), - 0 0.0625em 0.125em var(--djdt-warning-shadow); - font-family: var(--djdt-font-family-primary); - font-size: 0.875em; - line-height: 1.5; -} - -#djDebug .djdt-deprecation-warning::before { - content: "⚠️"; - font-size: 1.125em; - margin-right: 0.75em; - vertical-align: middle; -} - -#djDebug .djdt-deprecation-warning a { - color: var(--djdt-warning-link); - text-decoration: none; - font-weight: 500; - border-bottom: 0.0625em solid currentColor; - padding-bottom: 0.0625em; - transition: all 0.2s ease; -} - -#djDebug .djdt-deprecation-warning a:hover { - color: var(--djdt-warning-link-hover); - border-bottom-width: 0.125em; -} - -#djDebug .djdt-deprecation-warning strong { - color: var(--djdt-warning-strong); - font-weight: 600; -} diff --git a/debug_toolbar/templates/debug_toolbar/redirect.html b/debug_toolbar/templates/debug_toolbar/redirect.html index 169113aae..cb2bef316 100644 --- a/debug_toolbar/templates/debug_toolbar/redirect.html +++ b/debug_toolbar/templates/debug_toolbar/redirect.html @@ -5,10 +5,69 @@ Django Debug Toolbar Redirects Panel: {{ status_line }} + - +
- {% translate "WARNING:" %} {% translate "The RedirectsPanel is deprecated and will be removed in a future version. The HistoryPanel now provides the ability to view toolbar data for redirected requests. If you still have a use case for this panel, please comment on this issue" %} + {% translate "WARNING:" %} + {% blocktranslate with issue_url="https://github.com/django-commons/django-debug-toolbar/issues/2216" %} + The RedirectsPanel is deprecated and will be removed in a future version. The HistoryPanel + now provides the ability to view toolbar data for redirected requests. If you still have a + use case for this panel, please comment on this issue. + {% endblocktranslate %}

{{ status_line }}

{% translate "Location:" %} {{ redirect_to }}