aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar/toolbar.py
diff options
context:
space:
mode:
authorAymeric Augustin2013-12-15 13:16:12 +0100
committerAymeric Augustin2013-12-15 13:16:12 +0100
commit35a1cb5e27889931a3a94ad095b742a91399eee5 (patch)
treea3db8169a9c23e0cf02a6dd7b5f7eae9e97e1f23 /debug_toolbar/toolbar.py
parentf9420501367bb4e8eb65c3b131185f2544710bf5 (diff)
parent38de94d2d6586c716256838e41abe518898030d6 (diff)
downloaddjango-debug-toolbar-35a1cb5e27889931a3a94ad095b742a91399eee5.tar.bz2
Merge branch 'master' into 1.0-release
Diffstat (limited to 'debug_toolbar/toolbar.py')
-rw-r--r--debug_toolbar/toolbar.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/debug_toolbar/toolbar.py b/debug_toolbar/toolbar.py
index 36c301a..ec840dd 100644
--- a/debug_toolbar/toolbar.py
+++ b/debug_toolbar/toolbar.py
@@ -6,11 +6,16 @@ from __future__ import absolute_import, unicode_literals
import uuid
+from django.conf import settings
from django.conf.urls import patterns, url
from django.core.exceptions import ImproperlyConfigured
+from django.template import TemplateSyntaxError
from django.template.loader import render_to_string
-from django.utils.datastructures import SortedDict
from django.utils.importlib import import_module
+try:
+ from collections import OrderedDict
+except ImportError:
+ from django.utils.datastructures import SortedDict as OrderedDict
from debug_toolbar import settings as dt_settings
@@ -20,7 +25,7 @@ class DebugToolbar(object):
def __init__(self, request):
self.request = request
self.config = dt_settings.CONFIG.copy()
- self._panels = SortedDict()
+ self._panels = OrderedDict()
for panel_class in self.get_panel_classes():
panel_instance = panel_class(self)
self._panels[panel_instance.panel_id] = panel_instance
@@ -57,11 +62,21 @@ class DebugToolbar(object):
"""
if not self.should_render_panels():
self.store()
- return render_to_string('debug_toolbar/base.html', {'toolbar': self})
+ try:
+ context = {'toolbar': self}
+ return render_to_string('debug_toolbar/base.html', context)
+ except TemplateSyntaxError:
+ if 'django.contrib.staticfiles' not in settings.INSTALLED_APPS:
+ raise ImproperlyConfigured(
+ "The debug toolbar requires the staticfiles contrib app. "
+ "Add 'django.contrib.staticfiles' to INSTALLED_APPS and "
+ "define STATIC_URL in your settings.")
+ else:
+ raise
# Handle storing toolbars in memory and fetching them later on
- _store = SortedDict()
+ _store = OrderedDict()
def should_render_panels(self):
render_panels = self.config['RENDER_PANELS']