Skip to content

Instantly share code, notes, and snippets.

@emoss08
Created October 19, 2022 17:29
Show Gist options
  • Save emoss08/8a934c5d7eef676cc4d6b4934bec9839 to your computer and use it in GitHub Desktop.
Save emoss08/8a934c5d7eef676cc4d6b4934bec9839 to your computer and use it in GitHub Desktop.
# Prints SQL statements to console. Put this in your settings.py
LOGGING = {
'version': 1,
'filters': {
'require_debug_true': {
'()': 'django.utils.log.RequireDebugTrue',
}
},
'handlers': {
'console': {
'level': 'DEBUG',
'filters': ['require_debug_true'],
'class': 'logging.StreamHandler',
}
},
'loggers': {
'django.db.backends': {
'level': 'DEBUG',
'handlers': ['console'],
},
}
}
SHELL_PLUS_PRINT_SQL = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment