Skip to content

Console logs on dev are flooded with template variable resolution errors, making the logs unusable #2150

@talkingseed

Description

@talkingseed

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

  1. 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', ...}
  1. 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': []}
  1. 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

  1. Install Django Debug Toolbar in a Django 5.1 project
  2. Configure it according to the documentation
  3. Make any request to the application
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy