8👍
You can simply set in settings.py this logging configuration to have all SQL queries printed on the console
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
'django.db.backends': {
'handlers': ['console'],
'level': 'DEBUG'
},
}
}
This is the part responsible for printing
'django.db.backends': {
'handlers': ['console'],
'level': 'DEBUG'
},
3👍
I use the debug_toolbar: https://pypi.python.org/pypi/django-debug-toolbar
Check it out. It’s worth it.
- [Django]-Can I have 2 Django sites using 2 different version of Python on 1 domain?
- [Django]-Where to instantiate a client for an external service in Django?
Source:stackexchange.com