blob: c1c9f1aa903165a1c3d772c5a6762ce26e303a2f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
from debug_toolbar.panels import DebugPanel
from django.db import connection
from django.template import Context, Template
class SQLDebugPanel(DebugPanel):
"""
Panel that displays information about the SQL queries run while processing the request.
"""
def title(self):
return '%d SQL Queries' % (len(connection.queries))
def url(self):
return ''
def content(self):
t = Template('''
<dl>
{% for q in queries %}
<dt><strong>{{ q.time }}</strong></dt>
<dd>{{ q.sql }}</dd>
{% endfor %}
</dl>
''')
c = Context({'queries': connection.queries})
return t.render(c)
|