Django print out the statements executed in the database

Sometimes we need to look at models when the corresponding SQL statements,

You can use the following method to view ---

django project settings file in the following code tail

 

 1 LOGGING = {
 2     'version': 1,
 3     'disable_existing_loggers': False,
 4     'handlers': {
 5         'console': {
 6             'class': 'logging.StreamHandler',
 7         },
 8     },
 9     'loggers': {
10         'django.db.backends': {
11             'handlers': ['console'],
12             'level': 'DEBUG' if DEBUG else 'INFO',
13         },
14     },
15 }
View Code

 

Guess you like

Origin www.cnblogs.com/echo9908/p/11243819.html