Skip to content

Commit 7716a53

Browse files
committed
Merge pull request #495 from aaugustin/require-staticfiles
Be helpful when d.c.staticfiles isn't installed.
2 parents 6e4b255 + 3d420c0 commit 7716a53

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

debug_toolbar/toolbar.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
import uuid
88

9+
from django.conf import settings
910
from django.conf.urls import patterns, url
1011
from django.core.exceptions import ImproperlyConfigured
12+
from django.template import TemplateSyntaxError
1113
from django.template.loader import render_to_string
1214
from django.utils.datastructures import SortedDict
1315
from django.utils.importlib import import_module
@@ -57,7 +59,17 @@ def render_toolbar(self):
5759
"""
5860
if not self.should_render_panels():
5961
self.store()
60-
return render_to_string('debug_toolbar/base.html', {'toolbar': self})
62+
try:
63+
context = {'toolbar': self}
64+
return render_to_string('debug_toolbar/base.html', context)
65+
except TemplateSyntaxError:
66+
if 'django.contrib.staticfiles' not in settings.INSTALLED_APPS:
67+
raise ImproperlyConfigured(
68+
"The debug toolbar requires the staticfiles contrib app. "
69+
"Add 'django.contrib.staticfiles' to INSTALLED_APPS and "
70+
"define STATIC_URL in your settings.")
71+
else:
72+
raise
6173

6274
# Handle storing toolbars in memory and fetching them later on
6375

0 commit comments

Comments
 (0)