aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar
diff options
context:
space:
mode:
Diffstat (limited to 'debug_toolbar')
-rw-r--r--debug_toolbar/__init__.py2
-rw-r--r--debug_toolbar/panels/sql.py10
-rw-r--r--debug_toolbar/panels/template.py27
-rw-r--r--debug_toolbar/templates/debug_toolbar/panels/sql.html4
-rw-r--r--debug_toolbar/templates/debug_toolbar/panels/templates.html2
5 files changed, 28 insertions, 17 deletions
diff --git a/debug_toolbar/__init__.py b/debug_toolbar/__init__.py
index e2fa70b..6fa3081 100644
--- a/debug_toolbar/__init__.py
+++ b/debug_toolbar/__init__.py
@@ -1,2 +1,2 @@
-VERSION = (0, 7, 0)
+VERSION = (0, 8, 0)
__version__ = '.'.join(map(str, VERSION))
diff --git a/debug_toolbar/panels/sql.py b/debug_toolbar/panels/sql.py
index 17f4598..0c9bc61 100644
--- a/debug_toolbar/panels/sql.py
+++ b/debug_toolbar/panels/sql.py
@@ -1,7 +1,8 @@
+from datetime import datetime
import os
import SocketServer
-from datetime import datetime
import traceback
+
import django
from django.conf import settings
from django.db import connection
@@ -10,6 +11,7 @@ from django.template.loader import render_to_string
from django.utils import simplejson
from django.utils.encoding import force_unicode
from django.utils.hashcompat import sha_constructor
+
from debug_toolbar.panels import DebugPanel
# Figure out some paths
@@ -71,7 +73,8 @@ def tidy_stacktrace(strace):
trace = []
for s in strace[:-1]:
s_path = os.path.realpath(s[0])
- if django_path in s_path and not 'django/contrib' in s_path:
+ if getattr(settings, 'DEBUG_TOOLBAR_CONFIG', {}).get('HIDE_DJANGO_SQL', True) \
+ and django_path in s_path and not 'django/contrib' in s_path:
continue
if socketserver_path in s_path:
continue
@@ -106,7 +109,8 @@ class DatabaseStatTracker(util.CursorDebugWrapper):
'stacktrace': stacktrace,
'start_time': start,
'stop_time': stop,
- 'is_slow': (duration > SQL_WARNING_THRESHOLD)
+ 'is_slow': (duration > SQL_WARNING_THRESHOLD),
+ 'is_select': sql.lower().strip().startswith('select'),
})
util.CursorDebugWrapper = DatabaseStatTracker
diff --git a/debug_toolbar/panels/template.py b/debug_toolbar/panels/template.py
index 391902f..f090c78 100644
--- a/debug_toolbar/panels/template.py
+++ b/debug_toolbar/panels/template.py
@@ -37,16 +37,18 @@ class TemplateDebugPanel(DebugPanel):
def __init__(self):
self.templates = []
- template_rendered.connect(self._storeTemplateInfo)
+ template_rendered.connect(self._store_template_info)
- def _storeTemplateInfo(self, sender, **kwargs):
+ def _store_template_info(self, sender, **kwargs):
self.templates.append(kwargs)
def nav_title(self):
return _('Templates')
def title(self):
- return 'Templates'
+ num_templates = len([t for t in self.templates
+ if not t['template'].name.startswith('debug_toolbar/')])
+ return 'Templates (%s rendered)' % num_templates
def url(self):
return ''
@@ -75,15 +77,16 @@ class TemplateDebugPanel(DebugPanel):
t.origin_name = 'No origin'
info['template'] = t
# Clean up context for better readability
- c = d.get('context', None)
-
- d_list = []
- for _d in c.dicts:
- try:
- d_list.append(pformat(d))
- except UnicodeEncodeError:
- pass
- info['context'] = '\n'.join(d_list)
+ if getattr(settings, 'DEBUG_TOOLBAR_CONFIG', {}).get('SHOW_TEMPLATE_CONTEXT', True):
+ c = d.get('context', None)
+
+ d_list = []
+ for _d in c.dicts:
+ try:
+ d_list.append(pformat(d))
+ except UnicodeEncodeError:
+ pass
+ info['context'] = '\n'.join(d_list)
template_context.append(info)
context = {
'templates': template_context,
diff --git a/debug_toolbar/templates/debug_toolbar/panels/sql.html b/debug_toolbar/templates/debug_toolbar/panels/sql.html
index 81188a9..ba8a2c3 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/sql.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/sql.html
@@ -14,7 +14,9 @@
<td>{{ query.duration|floatformat:"2" }}</td>
<td>
{% if query.params %}
- <a class="remoteCall" href="/__debug__/sql_select/?sql={{ query.raw_sql|urlencode }}&params={{ query.params|urlencode }}&duration={{ query.duration|floatformat:"2"|urlencode }}&hash={{ query.hash }}">SELECT</a><br>
+ {% if query.is_select %}
+ <a class="remoteCall" href="/__debug__/sql_select/?sql={{ query.raw_sql|urlencode }}&params={{ query.params|urlencode }}&duration={{ query.duration|floatformat:"2"|urlencode }}&hash={{ query.hash }}">SELECT</a><br>
+ {% endif %}
<a class="remoteCall" href="/__debug__/sql_explain/?sql={{ query.raw_sql|urlencode }}&params={{ query.params|urlencode }}&duration={{ query.duration|floatformat:"2"|urlencode }}&hash={{ query.hash }}">EXPLAIN</a><br>
{% if is_mysql %}
<a class="remoteCall" href="/__debug__/sql_profile/?sql={{ query.raw_sql|urlencode }}&params={{ query.params|urlencode }}&duration={{ query.duration|floatformat:"2"|urlencode }}&hash={{ query.hash }}">PROFILE</a><br>
diff --git a/debug_toolbar/templates/debug_toolbar/panels/templates.html b/debug_toolbar/templates/debug_toolbar/panels/templates.html
index 1158abe..6107876 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/templates.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/templates.html
@@ -16,10 +16,12 @@
{% for template in templates %}
<dt><strong><a class="remoteCall toggleTemplate" href="/__debug__/template_source/?template={{ template.template.name }}">{{ template.template.name|addslashes }}</a></strong></dt>
<dd><samp>{{ template.template.origin_name|addslashes }}</samp></dd>
+ {% if template.context %}
<dd>
<div class="djTemplateShowContextDiv"><a class="djTemplateShowContext"><span class="toggleArrow">&#x25B6;</span> Toggle Context</a></div>
<div class="djTemplateHideContextDiv" style="display:none;"><pre>{{ template.context }}</pre></div>
</dd>
+ {% endif %}
{% endfor %}
</dl>
{% else %}