aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debug_toolbar/panels/sql.py3
-rw-r--r--debug_toolbar/templates/debug_toolbar/panels/sql.html4
2 files changed, 5 insertions, 2 deletions
diff --git a/debug_toolbar/panels/sql.py b/debug_toolbar/panels/sql.py
index 8edfce9..757505a 100644
--- a/debug_toolbar/panels/sql.py
+++ b/debug_toolbar/panels/sql.py
@@ -1,3 +1,4 @@
+import simplejson
import time
from debug_toolbar.panels import DebugPanel
from django.db import connection
@@ -20,7 +21,7 @@ class DatabaseStatTracker(util.CursorDebugWrapper):
'sql': self.db.ops.last_executed_query(self.cursor, sql, params),
'time': stop - start,
'raw_sql': sql,
- 'params': params,
+ 'params': simplejson.dumps(params),
})
util.CursorDebugWrapper = DatabaseStatTracker
diff --git a/debug_toolbar/templates/debug_toolbar/panels/sql.html b/debug_toolbar/templates/debug_toolbar/panels/sql.html
index 046be7f..9a6638b 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/sql.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/sql.html
@@ -4,13 +4,15 @@
<tr>
<th>Time&nbsp;(ms)</th>
<th>Query</th>
+ <th>Action</th>
</tr>
</thead>
<tbody>
{% for query in queries %}
<tr class="{% cycle 'row1' 'row2' %}">
<td>{{ query.time|floatformat:"4" }}</td>
- <td><pre>{{ query.sql|escape }}</pre></td>
+ <td><pre>{{ query.sql|wordwrap:80|escape }}</pre></td>
+ <td><a href="{% url explain_sql %}?sql={{ query.raw_sql|urlencode }}&params={{ query.params|urlencode }}&time={{ query.time|floatformat:"4"|urlencode }}">EXPLAIN</a></td>
</tr>
{% endfor %}
</tbody>