Skip to content

Be helpful when d.c.staticfiles isn't installed. #495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 10, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion debug_toolbar/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

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
Expand Down Expand Up @@ -57,7 +59,17 @@ def render_toolbar(self):
"""
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

Expand Down