Created
May 11, 2018 07:55
-
-
Save maheshgawali/de79e42104114619bcf1e970abb501da to your computer and use it in GitHub Desktop.
Django: show/log ORM sql calls from python shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# taken from -> https://stackoverflow.com/a/30394237/1035818 | |
# i hunt for this every once in a while, so creating the gist, all credits for this snippet at to the commenter from the link above | |
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()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment