Skip to content

Commit 1c1b442

Browse files
committed
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.
1 parent db2de5b commit 1c1b442

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

debug_toolbar/templates/debug_toolbar/base.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
{% load i18n %}{% load url from future %}
1+
{% load i18n %}{% load static from staticfiles %}{% load url from future %}
22
<style type="text/css">
33
@media print { #djDebug {display:none;}}
44
</style>
5-
<link rel="stylesheet" href="{{ STATIC_URL }}debug_toolbar/css/toolbar.css" type="text/css" />
5+
<link rel="stylesheet" href="{% static 'debug_toolbar/css/toolbar.css' %}" type="text/css" />
66
<script>//<![CDATA[
77
if(!window.jQuery) document.write('<scr'+'ipt src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></scr'+'ipt>');
88
//]]></script>
9-
<script src="{{ STATIC_URL }}debug_toolbar/js/jquery.cookie.js"></script>
10-
<script src="{{ STATIC_URL }}debug_toolbar/js/toolbar.js"></script>
9+
<script src="{% static 'debug_toolbar/js/jquery.cookie.js' %}"></script>
10+
<script src="{% static 'debug_toolbar/js/toolbar.js' %}"></script>
1111
<div id="djDebug" style="display:none;" dir="ltr"
1212
data-store-id="{{ toolbar.store_id }}" data-render-panel-url="{% url 'djdt:render_panel' %}"
1313
{{ toolbar.config.ROOT_TAG_EXTRA_ATTRS|safe }}>

debug_toolbar/templates/debug_toolbar/panels/profiling.html

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
{% load i18n %}
2-
1+
{% load i18n %}{% load static from staticfiles %}
32
<table width="100%">
43
<thead>
54
<tr>
@@ -42,4 +41,4 @@
4241
</tbody>
4342
</table>
4443

45-
<script src="{{ STATIC_URL }}debug_toolbar/js/toolbar.profiling.js"></script>
44+
<script src="{% static 'debug_toolbar/js/toolbar.profiling.js' %}"></script>

debug_toolbar/templates/debug_toolbar/panels/sql.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% load i18n l10n %}{% load url from future %}
1+
{% load i18n l10n %}{% load static from staticfiles %}{% load url from future %}
22
<div class="clearfix">
33
<ul class="stats">
44
{% for alias, info in databases %}
@@ -92,4 +92,4 @@
9292
<p>{% trans "No SQL queries were recorded during this request." %}</p>
9393
{% endif %}
9494

95-
<script src="{{ STATIC_URL }}debug_toolbar/js/toolbar.sql.js"></script>
95+
<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}"></script>

debug_toolbar/templates/debug_toolbar/panels/templates.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% load i18n %}{% load url from future %}
1+
{% load i18n %}{% load static from staticfiles %}{% load url from future %}
22
<h4>{% blocktrans count template_dirs|length as template_count %}Template path{% plural %}Template paths{% endblocktrans %}</h4>
33
{% if template_dirs %}
44
<ol>
@@ -43,4 +43,4 @@ <h4>{% blocktrans count context_processors|length as context_processors_count %}
4343
<p>{% trans 'None' %}</p>
4444
{% endif %}
4545

46-
<script src="{{ STATIC_URL }}debug_toolbar/js/toolbar.template.js"></script>
46+
<script src="{% static 'debug_toolbar/js/toolbar.template.js' %}"></script>

debug_toolbar/templates/debug_toolbar/panels/timer.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% load i18n %}
1+
{% load i18n %}{% load static from staticfiles %}
22
<h4>{% trans 'Resource Usage' %}</h4>
33
<table>
44
<colgroup>
@@ -41,4 +41,4 @@ <h4>{% trans 'Browser Timing' %}</h4>
4141
</tbody>
4242
</table>
4343
</div>
44-
<script src="{{ STATIC_URL }}debug_toolbar/js/toolbar.timer.js"></script>
44+
<script src="{% static 'debug_toolbar/js/toolbar.timer.js' %}"></script>

debug_toolbar/toolbar.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import uuid
88

9-
from django.conf import settings
109
from django.conf.urls import patterns, url
1110
from django.core.exceptions import ImproperlyConfigured
1211
from django.template.loader import render_to_string
@@ -21,10 +20,7 @@ class DebugToolbar(object):
2120
def __init__(self, request):
2221
self.request = request
2322
self.config = dt_settings.CONFIG.copy()
24-
self.template_context = {
25-
'STATIC_URL': settings.STATIC_URL,
26-
'toolbar': self,
27-
}
23+
self.template_context = {'toolbar': self}
2824
self._panels = SortedDict()
2925
for panel_class in self.get_panel_classes():
3026
panel_instance = panel_class(self, context=self.template_context)

docs/installation.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,18 @@ instead with the following command::
2222
Quick setup
2323
-----------
2424

25-
Add ``debug_toolbar`` to your ``INSTALLED_APPS`` setting::
25+
Make sure that ``'django.contrib.staticfiles'`` is set up properly and add
26+
``'debug_toolbar'`` to your ``INSTALLED_APPS`` setting::
2627

2728
INSTALLED_APPS = (
29+
# ...
30+
'django.contrib.staticfiles',
2831
# ...
2932
'debug_toolbar',
3033
)
3134

35+
STATIC_URL = '/static/'
36+
3237
For a simple Django project, that's all you need!
3338

3439
The Debug Toolbar will automatically adjust a few settings when you start the

0 commit comments

Comments
 (0)