From b02d72eab49535ffec4ddcb864b72753d823eb5f Mon Sep 17 00:00:00 2001 From: klmp200 Date: Sun, 26 Feb 2017 17:00:09 +0100 Subject: [PATCH] Fix debug-toolbar with jinja --- sith/settings.py | 14 ++++++++++++++ sith/toolbar_debug.py | 8 ++++++++ 2 files changed, 22 insertions(+) create mode 100644 sith/toolbar_debug.py diff --git a/sith/settings.py b/sith/settings.py index 877daab2..24b0ea62 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -492,3 +492,17 @@ except: if DEBUG: INSTALLED_APPS += ("debug_toolbar",) MIDDLEWARE_CLASSES = ('debug_toolbar.middleware.DebugToolbarMiddleware',) + MIDDLEWARE_CLASSES + DEBUG_TOOLBAR_PANELS = [ + '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', + 'debug_toolbar.panels.staticfiles.StaticFilesPanel', + 'sith.toolbar_debug.TemplatesPanel', + 'debug_toolbar.panels.cache.CachePanel', + 'debug_toolbar.panels.signals.SignalsPanel', + 'debug_toolbar.panels.logging.LoggingPanel', + 'debug_toolbar.panels.redirects.RedirectsPanel', + ] diff --git a/sith/toolbar_debug.py b/sith/toolbar_debug.py new file mode 100644 index 00000000..f168cd30 --- /dev/null +++ b/sith/toolbar_debug.py @@ -0,0 +1,8 @@ +from debug_toolbar.panels.templates import TemplatesPanel as BaseTemplatesPanel + +class TemplatesPanel(BaseTemplatesPanel): + def generate_stats(self, *args): + template = self.templates[0]['template'] + if not hasattr(template, 'engine') and hasattr(template, 'backend'): + template.engine = template.backend + return super().generate_stats(*args)