name '_mysql' is not defined 1

name ‘_mysql’ is not defined

mport pymysql  
pymysql.install_as_MySQLdb()
in setting file in django or django restframework

Here is what the above code is Doing:
1. It’s importing the pymysql module.
2. It’s installing the pymysql module as the MySQLdb module.
3. It’s importing the MySQLdb module.
4. It’s importing the django.db.backends.mysql module.
5. It’s replacing the MySQLdb module with the pymysql module.
6. It’s importing the django.db.backends.mysql module again.

Similar Posts