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

Release 4.4.4 seems to require Jinja2 #1952

Closed alorence closed 3 months ago

alorence commented 3 months ago

Hello,

I just upgraded django-debug-toolbar from 4.4.3 to 4.4.4. Unfortunately, I immediatly got an error due to the absence of jinja2 in my environment.

Traceback (most recent call last):
  File "/home/alorence/dev/projects/myproject/manage.py", line 29, in <module>
    main()
  File "/home/alorence/dev/projects/myproject/manage.py", line 25, in main
    execute_from_command_line(sys.argv)
  File "/home/alorence/.cache/pypoetry/virtualenvs/myproject-4kgUsWzL-py3.12/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/home/alorence/.cache/pypoetry/virtualenvs/myproject-4kgUsWzL-py3.12/lib/python3.12/site-packages/django/core/management/__init__.py", line 416, in execute
    django.setup()
  File "/home/alorence/.cache/pypoetry/virtualenvs/myproject-4kgUsWzL-py3.12/lib/python3.12/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/alorence/.cache/pypoetry/virtualenvs/myproject-4kgUsWzL-py3.12/lib/python3.12/site-packages/django/apps/registry.py", line 124, in populate
    app_config.ready()
  File "/home/alorence/.cache/pypoetry/virtualenvs/myproject-4kgUsWzL-py3.12/lib/python3.12/site-packages/debug_toolbar/apps.py", line 25, in ready
    for cls in DebugToolbar.get_panel_classes():
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alorence/.cache/pypoetry/virtualenvs/myproject-4kgUsWzL-py3.12/lib/python3.12/site-packages/debug_toolbar/toolbar.py", line 136, in get_panel_classes
    import_string(panel_path) for panel_path in dt_settings.get_panels()
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alorence/.cache/pypoetry/virtualenvs/myproject-4kgUsWzL-py3.12/lib/python3.12/site-packages/django/utils/module_loading.py", line 30, in import_string
    return cached_import(module_path, class_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alorence/.cache/pypoetry/virtualenvs/myproject-4kgUsWzL-py3.12/lib/python3.12/site-packages/django/utils/module_loading.py", line 15, in cached_import
    module = import_module(module_path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/alorence/.cache/pypoetry/virtualenvs/myproject-4kgUsWzL-py3.12/lib/python3.12/site-packages/debug_toolbar/panels/templates/__init__.py", line 1, in <module>
    from debug_toolbar.panels.templates.panel import TemplatesPanel
  File "/home/alorence/.cache/pypoetry/virtualenvs/myproject-4kgUsWzL-py3.12/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 "/home/alorence/.cache/pypoetry/virtualenvs/myproject-4kgUsWzL-py3.12/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 "/home/alorence/.cache/pypoetry/virtualenvs/myproject-4kgUsWzL-py3.12/lib/python3.12/site-packages/django/template/backends/jinja2.py", line 3, in <module>
    import jinja2
ModuleNotFoundError: No module named 'jinja2'

I see that some changes were made around jinja2 management in that release, is there something missing in my config to prevent debugtoolbar trying to import jinja2?

By the way, I use debug-toolbar for years now, it is the first app I install in any nw project. This is a great tool, thank you a lot for maintaining it !

Best regards

Zerotask commented 3 months ago

We noticed the same error with 4.4.4

danjac commented 3 months ago

Duplicate of #1949

alorence commented 3 months ago

Duplicate of #1949

Sorry about that, I checked too quickly for existing issues. Closing this