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

Exception while resolving variable 'toolbar' in template #1905

Closed foundkey closed 6 months ago

foundkey commented 6 months ago

When sending a request using ajax, toolbar.js will send a request at the same time: GET /__debug__/history_sidebar/?store_id=<id> HTTP/1.1

This request will throw the following exception when rendering the template:

Traceback (most recent call last): File "/Users/.venv/lib/python3.10/site-packages/django/template/base.py", line 898, in _resolve_lookup raise VariableDoesNotExist( django.template.base.VariableDoesNotExist: Failed lookup for key [toolbar] in [{'True': True, 'False': False, 'None': None}, {'panel': <debug_toolbar.panels.cache.CachePanel object at 0x11f936590>}] [DEBUG] 12/Apr/2024 10:31:22 - Exception while resolving variable 'toolbar' in template 'debug_toolbar/includes/panel_content.html'. Traceback (most recent call last): File "/Users/.venv/lib/python3.10/site-packages/django/template/base.py", line 875, in _resolve_lookup current = current[bit] File "/Users/.venv/lib/python3.10/site-packages/django/template/context.py", line 83, in getitem raise KeyError(key) KeyError: 'toolbar'

This request is handled by this method: history_sidebar(request) It seems because toolbar is not passed in panel_context.

foundkey commented 6 months ago

After turning on Debug level logging, VariableDoesNotExist errors appear frequently during use. But it does not affect the use.

tim-schilling commented 6 months ago

Hmm. I'm softening on my earlier stance on the PR.

Riskcomplexx commented 2 months ago

I'm currently seeing the same thing but oddly only in firefox and not chrome.

JasonSanDiego commented 1 week ago

I see the issue on Chrome also

tim-schilling commented 6 days ago

@Riskcomplexx @JasonSanDiego I appreciate your seconding of the issue, but what will help get this resolve a reproducible example. Would you be able to provide one?