django-commons / django-debug-toolbar

A configurable set of panels that display various debug information about the current request/response.
https://django-debug-toolbar.readthedocs.io
BSD 3-Clause "New" or "Revised" License
8.08k stars 1.05k forks source link

Jinja2 dependency breaks default install #1949

Closed danjac closed 3 months ago

danjac commented 3 months ago

Version: 4.4.4 Django version: 5.0.6

Default toolbar settings

On startup Django crashes:

File "/my-project/.venv/lib/python3.12/site-packages/debug_toolbar/panels/templates/__init__.py", line 1, in <module>
    from debug_toolbar.panels.templates.panel import TemplatesPanel
  File "/my-project/.venv/lib/python3.12/site-packages/debug_toolbar/panels/templates/panel.py", line 17, in <module>
    from debug_toolbar.panels.templates.jinja2 import patch_jinja_render
  File "/my-project/.venv/lib/python3.12/site-packages/debug_toolbar/panels/templates/jinja2.py", line 3, in <module>
    from django.template.backends.jinja2 import Template as JinjaTemplate
  File "/my-project/.venv/lib/python3.12/site-packages/django/template/backends/jinja2.py", line 3, in <module>
    import jinja2
ModuleNotFoundError: No module named 'jinja2'

It looks like jinja2 is required for the TemplatesPanel - in my project this is not a dependency. Either jinja2 is included as a dependency, or we check it is present, or the requirement is documented.

matthiask commented 3 months ago

Thanks for the report! #1954 hopefully fixes this.