{% if debug %}
<div id="debug">
<h2>Queries</h2>
<p>
{{ sql_queries|length }} Quer{{ sql_queries|pluralize:"y,ies" }}
{% ifnotequal sql_queries|length 0 %}
(<span style="cursor: pointer;" onclick="var s=document.getElementById('debugQueryTable').style;s.display=s.display=='none'?'':'none';this.innerHTML=this.innerHTML=='Show'?'Hide':'Show';">Show</span>)
{% endifnotequal %}
</p>
<table id="debugQueryTable" style="display: none;">
<col width="1"></col>
<col></col>
<col width="1"></col>
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">SQL</th>
<th scope="col">Time</th>
</tr>
</thead>
<tbody>
{% for query in sql_queries %}<tr class="{% cycle odd,even %}">
<td>{{ forloop.counter }}</td>
<td>{{ query.sql|escape }}</td>
<td>{{ query.time }}</td>
</tr>{% endfor %}
</tbody>
</table>
</div>
{% endif %}
Comments
Thanks for the great snip! Wonderful tool for debugging 'slow pages'!
#
Cool!
I have little troubles with displaying long rows of queries. For example:
If you have a LOT of colX, they aren't wrapped in browser, and queries are bad to read.
So, I make little modification. I wrote custom filter, which replace character "," (comma) to ", " (comma and space). Now I could read debug SQL queries more comfortably.
My custom filter
Modification of your template (row 24)
Thank you for great snippet, insin.
#
thank you both insin for the snippet and msgre for the filter, however, i noticed a bug with the filter
the expression:
matches the first character after the comma (non-space), so after the sub call it is replacing that character with a space
i only caught this after realizing there was a missing " before each column
i swapped that out for:
and it seems to be working a-ok
#
I'm using this snippets with the modifications in the comments but I've found useful to add this templatetags:
and to restrict the number of queries printed like this:
Some of my views are used for validation and run up to a few hundred thousand queries, which is a bit too much to print in a browser.
#
Very helpful snippen. Tanks.
By the way... in current Django SVN version You don't have to set TEMPLATE_CONTEXT_PROCESSORS, it's on by default.
#
Brilliant works like a charm :)
af
#
Awesome snippet. Simple, clean, and effective...
#
Hello,
I am new to django and i justed started to play around with django. I've copied this snippet to my base template but I can't see anything?
I checked every of the three steps mentioned above, the context processors are set by default and my ip is on INTERNAL_IPS. I don't understand what the third point means but I've added a request context to shortcut for rendering templates.
What can I do to get it work? Thanks for your help in advance and sorry for my bad english.
analyzer
#
nice !
#
Do you acknowledge that it's high time to receive the personal loans, which will realize your dreams.
#
Hello, everybody, the good shoping place, the new season approaching, click in. Welcome to ==== http://www.proxy4biz.com == Air Jordan (1-24) shoes $35 Jordan (1-22)&2009 shoes $45 Nike shox (R4, NZ, OZ, TL1, TL2, TL3) $35 Handbags ( Coach Lv fendi D&G) $30 T-shirts (polo, ed hardy, lacoste) $14 Jean (True Religion, ed hardy, coogi)$34 Sunglasses ( Oakey, coach, Gucci, Armaini)$15 New era cap $16 Biki ni (Ed hardy, polo) $18
FREE SHIPPING http://www.proxy4biz.com
http://www.proxy4biz.com
http://www.proxy4biz.com
http://www.proxy4biz.com http://www.proxy4biz.com
http://www.proxy4biz.com
http://www.proxy4biz.com
http://www.proxy4biz.com
===( http://www.proxy4biz.com )===
===( http://www.proxy4biz.com )===
===( http://www.proxy4biz.com )===
===( http://www.proxy4biz.com )===
===( http://www.proxy4biz.com )===
===( http://www.proxy4biz.com )=== This is a shopping paradise We need your support and trust 、
#
2egoo . com offers products and services of great value for the shoppers and try to make a large clientele. Please feel free to have a look around and make contact with us if you have any questions. We have become a company representative and distributor of compatible electronics accessories, especially of laptop accessories: [url=http://www.2egoo.com/]All Categories[/url], [url=http://www.2egoo.com/cpucoolingfan/cpucoolingfan.html]CPU Fan[/url], [url=http://www.2egoo.com/inverter/inverter.html]Inverter[/url], [url=http://www.2egoo.com/powerjack/powerjack.html]Power Jack[/url], [url=http://www.2egoo.com/keyboard/keyboard.html]Keyboard[/url], [url=http://www.2egoo.com/hinge/hinge.html]Hinge[/url], [url=http://www.2egoo.com/videocable/videocable.html]Video Cable[/url], [url=http://www.2egoo.com/batterycharger/batterycharger.html]Charger[/url]; and even dslr camera and cam corder batteries and chargers, diy equipment batteries, and also other products.For more information: *www.2egoo.com* **Apple MacBook 13 inch MA472SA A CPU Cooling Fan$26.99 ** === ===Apple MacBook 13 inch MA701 A CPU Cooling Fan Shop Price: $26.99=== ====== ===
#
In order to acquire the best brand-new Digital Camera battery at most favored price, you have got visited the best place. This site offers the highest quality battery while using the lowest price considering the highest higher level of service, all in a very secure and convenient platform. Our range of products include replacement Camera battery for almost all famous labels, including Acer Battery , BenQ Battery, Canon Battery, Casio Battery, Fujifilm Battery, HP Battery, Kodak Battery, Nikon Battery, Olympus Battery, Panasonic Battery, Ricoh Battery, Samsung Battery, and many others. To read more: www.aa-battery-charger.co.uk/!!
#