Login

Output sql_queries in Firebug console when in debug mode

Author:
wojas
Posted:
March 18, 2010
Language:
HTML/template
Version:
Not specified
Score:
5 (after 5 ratings)

Add this code to the end of the <body> of your main template and it will print out all your SQL queries with timings in the Firebug console.

This uses the "django.core.context_processors.debug" template context processor, which requires that DEBUG=True and that your IP address is listed in INTERNAL_IPS.

1
2
3
4
5
6
7
{% if debug %}
<script type="text/javascript">
  {% for q in sql_queries %}
    console.debug("({{ q.time }}s)", "{{ q.sql|escapejs }}");
  {% endfor %}
</script> 
{% endif %}

More like this

  1. Bootstrap Accordian by Netplay4 5 years, 3 months ago
  2. Bootstrap theme for django-endless-pagination? by se210 8 years, 3 months ago
  3. Bootstrap theme for django-endless-pagination? by se210 8 years, 3 months ago
  4. Reusable form template with generic view by roldandvg 8 years, 4 months ago
  5. Pagination Django with Boostrap by guilegarcia 8 years, 6 months ago

Comments

Please login first before commenting.