Ticket #1979: debug_queries.diff

File debug_queries.diff, 1.4 KB (added by Simon Greenhill, dev@…, 18 years ago)
  • debug.py

     
    22from django.template import Template, Context, TemplateDoesNotExist
    33from django.utils.html import escape
    44from django.http import HttpResponseServerError, HttpResponseNotFound
     5from django.db import connection
    56import os, re
    67from itertools import count, izip
    78from os.path import dirname, join as pathjoin
     
    120121        'request': request,
    121122        'request_protocol': os.environ.get("HTTPS") == "on" and "https" or "http",
    122123        'settings': get_safe_settings(),
     124        'database_queries' : connection.queries,
    123125        'template_info': template_info,
    124126        'template_does_not_exist': template_does_not_exist,
    125127        'loader_debug_info': loader_debug_info,
     
    522524      {% endfor %}
    523525    </tbody>
    524526  </table>
    525 
     527 
     528  <h3>Queries</h3>
     529  {% if database_queries %}
     530    <table class="req">
     531        <thead>
     532          <tr>
     533            <th>Duration</th>
     534            <th>Query</th>
     535          </tr>
     536        </thead>
     537        <tbody>
     538          {% for var in database_queries %}
     539            <tr>
     540              <td>{{ var.time }}</td>
     541              <td class="code"><div>{{ var.sql|escape }}</div></td>
     542            </tr>
     543          {% endfor %}
     544        </tbody>
     545     </table>
     546  {% else %}
     547    <p>No Query data</p>
     548  {% endif %}
     549 
    526550</div>
    527551
    528552<div id="explanation">
Back to Top