ORM
see SQL( One ): With the help of the log system
In operation ORM When , Focus on the operation of the database sql It's a key message , It's good for learning django Of orm Model , And you can learn about databases, and all that's relevant is , what's more , Can help us better optimize the query
In the project settings.json Add the following code to , It enables us to view the database operation every time sql
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console':{
'level':'DEBUG',
'class':'logging.StreamHandler',
},
},
'loggers': {
'django.db.backends': {
'handlers': ['console'],
'propagate': True,
'level':'DEBUG',
},
}
}