1. mysql database first need to install the driver
pip install PyMySQL
2.django can not directly manipulate pymysql, can only control mysqldb, it is necessary to do some conversion
Add the following statement in the project of the same name __init__.py file in a subdirectory of Django
Import install_as_MySQLdb pymysql from
install_as_MySQLdb (http://www.my516.com)
3. Modify configuration DATABASES
= {DATABASES
'default': {
'ENGINE': 'django.db.backends.mysql',
'the HOST': '127.0.0.1', # database host
'PORT': 3306, # database port
'USER': 'root ', # database user name
' pASSWORD ':' mysql ', # database user password
' nAME ':' django_demo '# database name
}
}
---------------------