Show SQL

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
django.core.context_processors.debug
INTERNAL_IPS
debug = True
#template
{{ sql_queries }}
#or
{% for i in sql_queries %}
{{ i.time }}<br />
{{ i.sql }}<br />
<br />
{% endfor %}
#view.py should return RequestContext, not simple Context
################################################################
from django.db import connection
connection.queries[-1]