diff --git a/README.rst b/README.rst index fa12e35c1..4e195a796 100644 --- a/README.rst +++ b/README.rst @@ -44,7 +44,7 @@ Here's a screenshot of the toolbar in action: In addition to the built-in panels, a number of third-party panels are contributed by the community. -The current stable version of the Debug Toolbar is 4.4.4. It works on +The current stable version of the Debug Toolbar is 4.4.5. It works on Django ≥ 4.2.0. The Debug Toolbar does not currently support `Django's asynchronous views diff --git a/debug_toolbar/__init__.py b/debug_toolbar/__init__.py index f5f18057b..a1a09f2a1 100644 --- a/debug_toolbar/__init__.py +++ b/debug_toolbar/__init__.py @@ -4,7 +4,7 @@ # Do not use pkg_resources to find the version but set it here directly! # see issue #1446 -VERSION = "4.4.4" +VERSION = "4.4.5" # Code that discovers files or modules in INSTALLED_APPS imports this module. urls = "debug_toolbar.urls", APP_NAME diff --git a/debug_toolbar/panels/alerts.py b/debug_toolbar/panels/alerts.py index 32c656dde..e640dcdd5 100644 --- a/debug_toolbar/panels/alerts.py +++ b/debug_toolbar/panels/alerts.py @@ -83,8 +83,7 @@ def __init__(self, *args, **kwargs): @property def nav_subtitle(self): - alerts = self.get_stats()["alerts"] - if alerts: + if alerts := self.get_stats().get("alerts"): alert_text = "alert" if len(alerts) == 1 else "alerts" return f"{len(alerts)} {alert_text}" else: diff --git a/debug_toolbar/panels/templates/panel.py b/debug_toolbar/panels/templates/panel.py index 182f80aab..ee2a066c7 100644 --- a/debug_toolbar/panels/templates/panel.py +++ b/debug_toolbar/panels/templates/panel.py @@ -1,4 +1,5 @@ from contextlib import contextmanager +from importlib.util import find_spec from os.path import normpath from pprint import pformat, saferepr @@ -14,7 +15,11 @@ from debug_toolbar.panels import Panel from debug_toolbar.panels.sql.tracking import SQLQueryTriggered, allow_sql from debug_toolbar.panels.templates import views -from debug_toolbar.panels.templates.jinja2 import patch_jinja_render + +if find_spec("jinja2"): + from debug_toolbar.panels.templates.jinja2 import patch_jinja_render + + patch_jinja_render() # Monkey-patch to enable the template_rendered signal. The receiver returns # immediately when the panel is disabled to keep the overhead small. @@ -26,8 +31,6 @@ Template.original_render = Template._render Template._render = instrumented_test_render -patch_jinja_render() - # Monkey-patch to store items added by template context processors. The # overhead is sufficiently small to justify enabling it unconditionally. diff --git a/docs/changes.rst b/docs/changes.rst index 539c9883c..952e6e996 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -4,6 +4,12 @@ Change log Pending ------- +4.4.5 (2024-07-05) +------------------ + +* Avoided crashing when the alerts panel was skipped. +* Removed the inadvertently added hard dependency on Jinja2. + 4.4.4 (2024-07-05) ------------------ diff --git a/docs/conf.py b/docs/conf.py index b155e44ef..8b9d06396 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,7 +25,7 @@ copyright = copyright.format(datetime.date.today().year) # The full version, including alpha/beta/rc tags -release = "4.4.4" +release = "4.4.5" # -- General configuration ---------------------------------------------------