Jay Taylor's notes

back to listing index

django orm, how to view (or log) the executed query? - Stack Overflow

[web search]
Original source (stackoverflow.com)
Tags: django orm database logging python stackoverflow.com
Clipped on: 2012-08-14
LOGGING = {
   
'disable_existing_loggers': False,
   
'version': 1
   
'handlers': {
       
'console': {
           
# logging handler that outputs log messages to terminal
           
'class': 'logging.StreamHandler',
           
'level': 'DEBUG', # message level to be written to console
       
},
   
},
   
'loggers': {
       
'': {
           
# this sets root level logger to log debug and higher level
           
# logs to console. All other loggers inherit settings from
           
# root level logger.
           
'handlers': ['console'],
           
'level': 'DEBUG',
           
'propagate': False, # this tells logger to send logging message
                               
# to its parent (will send if set to True)
       
},
       
'django.db': {
           
# django also has database level logging
       
},
   
},
}