-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Environment
- Django version: 5.1.x
- Django Debug Toolbar Version: 4.4.6
- Python version: 3.12
- Database: PostgreSQL
Description
When using Django Debug Toolbar in development, the console logs are flooded with template variable resolution errors, making the logs unusable. The errors occur repeatedly for every request.
Error Messages
- SQL Panel Errors:
Exception while resolving variable 'starts_trans' in template 'debug_toolbar/panels/sql.html'.
django.template.base.VariableDoesNotExist: Failed lookup for key [starts_trans] in {'vendor': 'postgresql', ...}
Exception while resolving variable 'ends_trans' in template 'debug_toolbar/panels/sql.html'.
django.template.base.VariableDoesNotExist: Failed lookup for key [ends_trans] in {'vendor': 'postgresql', ...}
Exception while resolving variable 'similar_count' in template 'debug_toolbar/panels/sql.html'.
django.template.base.VariableDoesNotExist: Failed lookup for key [similar_count] in {'vendor': 'postgresql', ...}
Exception while resolving variable 'duplicate_count' in template 'debug_toolbar/panels/sql.html'.
django.template.base.VariableDoesNotExist: Failed lookup for key [duplicate_count] in {'vendor': 'postgresql', ...}
Exception while resolving variable 'in_trans' in template 'debug_toolbar/panels/sql.html'.
django.template.base.VariableDoesNotExist: Failed lookup for key [in_trans] in {'vendor': 'postgresql', ...}
- Request Panel Errors:
Exception while resolving variable 'raw' in template 'debug_toolbar/panels/request.html'.
django.template.base.VariableDoesNotExist: Failed lookup for key [raw] in {'list': []}
- Templates Panel Errors:
AttributeError: 'dict' object has no attribute 'ends_trans'
AttributeError: 'dict' object has no attribute 'starts_trans'
Expected Behavior
Debug toolbar should work without flooding the console with template variable resolution errors.
Actual Behavior
Every request generates dozens of template variable errors in the console, making development logs unusable. The debug toolbar still functions, but the noise in the logs makes it difficult to see actual application errors or debug output.
Steps to Reproduce
- Install Django Debug Toolbar in a Django 5.1 project
- Configure it according to the documentation
- Make any request to the application
- Observe the console output filled with template variable errors
Workaround Attempted
Had to disable SQL and Templates panels to reduce log noise:
DEBUG_TOOLBAR_PANELS = [
'debug_toolbar.panels.history.HistoryPanel',
'debug_toolbar.panels.versions.VersionsPanel',
'debug_toolbar.panels.timer.TimerPanel',
'debug_toolbar.panels.settings.SettingsPanel',
'debug_toolbar.panels.headers.HeadersPanel',
'debug_toolbar.panels.request.RequestPanel',
# 'debug_toolbar.panels.sql.SQLPanel', # Disabled due to errors
'debug_toolbar.panels.staticfiles.StaticFilesPanel',
# 'debug_toolbar.panels.templates.TemplatesPanel', # Disabled due to errors
'debug_toolbar.panels.cache.CachePanel',
'debug_toolbar.panels.signals.SignalsPanel',
'debug_toolbar.panels.logging.LoggingPanel',
'debug_toolbar.panels.redirects.RedirectsPanel',
'debug_toolbar.panels.profiling.ProfilingPanel',
]
Possible Cause
It appears that the SQL panel template expects certain attributes (starts_trans
, ends_trans
, similar_count
, duplicate_count
, in_trans
) on query dictionaries that aren't being provided by the panel's context generation.
Additional Context
- Running behind nginx proxy with SSL
- Using PostgreSQL database
- The debug toolbar still functions correctly despite the errors
- The errors only appear in console logs, not in the browser
Would appreciate any guidance on resolving this issue or if this is a known compatibility issue with Django 5.1.