aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAymeric Augustin2013-11-24 12:05:28 +0100
committerAymeric Augustin2013-11-24 12:09:47 +0100
commit1c1b4428642254f4e6b05e93bd135b894f708eeb (patch)
tree0fc76a8c22a4dc25a5b48143a19947f390e3c28b
parentdb2de5b85ac1ae099b91bae402d21d6ea36ef306 (diff)
downloaddjango-debug-toolbar-1c1b4428642254f4e6b05e93bd135b894f708eeb.tar.bz2
Take advantage of django.contrib.staticfiles to serve static files.
It is the de facto standard nowadays and there's no good reason not to use it.
-rw-r--r--debug_toolbar/templates/debug_toolbar/base.html8
-rw-r--r--debug_toolbar/templates/debug_toolbar/panels/profiling.html5
-rw-r--r--debug_toolbar/templates/debug_toolbar/panels/sql.html4
-rw-r--r--debug_toolbar/templates/debug_toolbar/panels/templates.html4
-rw-r--r--debug_toolbar/templates/debug_toolbar/panels/timer.html4
-rw-r--r--debug_toolbar/toolbar.py6
-rw-r--r--docs/installation.rst7
7 files changed, 19 insertions, 19 deletions
diff --git a/debug_toolbar/templates/debug_toolbar/base.html b/debug_toolbar/templates/debug_toolbar/base.html
index 8a5e070..a9d82dc 100644
--- a/debug_toolbar/templates/debug_toolbar/base.html
+++ b/debug_toolbar/templates/debug_toolbar/base.html
@@ -1,13 +1,13 @@
-{% load i18n %}{% load url from future %}
+{% load i18n %}{% load static from staticfiles %}{% load url from future %}
<style type="text/css">
@media print { #djDebug {display:none;}}
</style>
-<link rel="stylesheet" href="{{ STATIC_URL }}debug_toolbar/css/toolbar.css" type="text/css" />
+<link rel="stylesheet" href="{% static 'debug_toolbar/css/toolbar.css' %}" type="text/css" />
<script>//<![CDATA[
if(!window.jQuery) document.write('<scr'+'ipt src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></scr'+'ipt>');
//]]></script>
-<script src="{{ STATIC_URL }}debug_toolbar/js/jquery.cookie.js"></script>
-<script src="{{ STATIC_URL }}debug_toolbar/js/toolbar.js"></script>
+<script src="{% static 'debug_toolbar/js/jquery.cookie.js' %}"></script>
+<script src="{% static 'debug_toolbar/js/toolbar.js' %}"></script>
<div id="djDebug" style="display:none;" dir="ltr"
data-store-id="{{ toolbar.store_id }}" data-render-panel-url="{% url 'djdt:render_panel' %}"
{{ toolbar.config.ROOT_TAG_EXTRA_ATTRS|safe }}>
diff --git a/debug_toolbar/templates/debug_toolbar/panels/profiling.html b/debug_toolbar/templates/debug_toolbar/panels/profiling.html
index 34ecc87..9d34043 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/profiling.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/profiling.html
@@ -1,5 +1,4 @@
-{% load i18n %}
-
+{% load i18n %}{% load static from staticfiles %}
<table width="100%">
<thead>
<tr>
@@ -42,4 +41,4 @@
</tbody>
</table>
-<script src="{{ STATIC_URL }}debug_toolbar/js/toolbar.profiling.js"></script>
+<script src="{% static 'debug_toolbar/js/toolbar.profiling.js' %}"></script>
diff --git a/debug_toolbar/templates/debug_toolbar/panels/sql.html b/debug_toolbar/templates/debug_toolbar/panels/sql.html
index 33c496c..599f194 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/sql.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/sql.html
@@ -1,4 +1,4 @@
-{% load i18n l10n %}{% load url from future %}
+{% load i18n l10n %}{% load static from staticfiles %}{% load url from future %}
<div class="clearfix">
<ul class="stats">
{% for alias, info in databases %}
@@ -92,4 +92,4 @@
<p>{% trans "No SQL queries were recorded during this request." %}</p>
{% endif %}
-<script src="{{ STATIC_URL }}debug_toolbar/js/toolbar.sql.js"></script>
+<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}"></script>
diff --git a/debug_toolbar/templates/debug_toolbar/panels/templates.html b/debug_toolbar/templates/debug_toolbar/panels/templates.html
index dbe93f8..18da4c9 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/templates.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/templates.html
@@ -1,4 +1,4 @@
-{% load i18n %}{% load url from future %}
+{% load i18n %}{% load static from staticfiles %}{% load url from future %}
<h4>{% blocktrans count template_dirs|length as template_count %}Template path{% plural %}Template paths{% endblocktrans %}</h4>
{% if template_dirs %}
<ol>
@@ -43,4 +43,4 @@
<p>{% trans 'None' %}</p>
{% endif %}
-<script src="{{ STATIC_URL }}debug_toolbar/js/toolbar.template.js"></script>
+<script src="{% static 'debug_toolbar/js/toolbar.template.js' %}"></script>
diff --git a/debug_toolbar/templates/debug_toolbar/panels/timer.html b/debug_toolbar/templates/debug_toolbar/panels/timer.html
index 977386d..11c5984 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/timer.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/timer.html
@@ -1,4 +1,4 @@
-{% load i18n %}
+{% load i18n %}{% load static from staticfiles %}
<h4>{% trans 'Resource Usage' %}</h4>
<table>
<colgroup>
@@ -41,4 +41,4 @@
</tbody>
</table>
</div>
-<script src="{{ STATIC_URL }}debug_toolbar/js/toolbar.timer.js"></script>
+<script src="{% static 'debug_toolbar/js/toolbar.timer.js' %}"></script>
diff --git a/debug_toolbar/toolbar.py b/debug_toolbar/toolbar.py
index de9d69d..d50ad52 100644
--- a/debug_toolbar/toolbar.py
+++ b/debug_toolbar/toolbar.py
@@ -6,7 +6,6 @@ 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.loader import render_to_string
@@ -21,10 +20,7 @@ class DebugToolbar(object):
def __init__(self, request):
self.request = request
self.config = dt_settings.CONFIG.copy()
- self.template_context = {
- 'STATIC_URL': settings.STATIC_URL,
- 'toolbar': self,
- }
+ self.template_context = {'toolbar': self}
self._panels = SortedDict()
for panel_class in self.get_panel_classes():
panel_instance = panel_class(self, context=self.template_context)
diff --git a/docs/installation.rst b/docs/installation.rst
index 5d046a2..2522e34 100644
--- a/docs/installation.rst
+++ b/docs/installation.rst
@@ -22,13 +22,18 @@ instead with the following command::
Quick setup
-----------
-Add ``debug_toolbar`` to your ``INSTALLED_APPS`` setting::
+Make sure that ``'django.contrib.staticfiles'`` is set up properly and add
+``'debug_toolbar'`` to your ``INSTALLED_APPS`` setting::
INSTALLED_APPS = (
# ...
+ 'django.contrib.staticfiles',
+ # ...
'debug_toolbar',
)
+ STATIC_URL = '/static/'
+
For a simple Django project, that's all you need!
The Debug Toolbar will automatically adjust a few settings when you start the