check db calls django

Solutions on MaxInterview for check db calls django by the best coders in the world

showing results for - "check db calls django"
Laura
11 Jul 2016
1from django.conf import settings
2settings.DEBUG = True
3from django.db import connection, reset_queries
4
5
6def num_queries(reset=True):
7    print(len(connection.queries))
8    if reset:
9        reset_queries()
10
Hannah
05 Jun 2018
1from django.conf import settings
2settings.DEBUG = True
3from django.db import connection
4Model.objects.count()
5# python 3 uses print()
6print(len(connection.queries))
71
8