Reputation: 2316
Is there a way to time sql queries in Django?
I know there's such thing in dj debug toolbar but I just need to display time on my web-page.
Since I can get a number of queries with:
len(connection.queries)
Maybe there's a similar way to get the time?
Upvotes: 0
Views: 95
Reputation: 3588
You can show them in templates if you have django.template.context_processors.debug available in your template settings.
It attaches sql_queries
list to template.
{% for query in sql_queries %}
{{ query.time }}
{% endfor %}
Make sure that DEBUG is True in your settings and request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS
Of course if you need something more this might help you.
Upvotes: 1