Answers for "check db calls django"

1

check db calls django

from django.conf import settings
settings.DEBUG = True
from django.db import connection, reset_queries


def num_queries(reset=True):
    print(len(connection.queries))
    if reset:
        reset_queries()
Posted by: Guest on August-06-2021
0

check db calls django

from django.conf import settings
settings.DEBUG = True
from django.db import connection
Model.objects.count()
# python 3 uses print()
print(len(connection.queries))
1
Posted by: Guest on August-06-2021

Python Answers by Framework

Browse Popular Code Answers by Language