Using the excellent Django-Devserver I\'m finding all kinds of interesting and unexpected SQL calls in my code. I wanted to find where the calls are coming from, and so I\'m
I was trying to use "Django: show/log ORM sql calls from python shell" in a shell on a production server, and it wasn't working. Eventually someone pointed out that it will only do this debug logging when DEBUG = True. But you can work around that like this:
import logging
from django.db import connection
connection.force_debug_cursor = True # Change to use_debug_cursor in django < 1.8
l = logging.getLogger('django.db.backends')
l.setLevel(logging.DEBUG)
l.addHandler(logging.StreamHandler())
I'm leaving this here so I can find it later, and hopefully it saves someone else the same digging I did.