Section thirty-sixth connect to the MySQL database configuration

In the configuration setting.py

 1 DATABASES = {
 2     'default': {
 3         # 'ENGINE': 'django.db.backends.sqlite3',
 4         # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
 5         'ENGINE': 'django.db.backends.mysql',
 6         'NAME':'bj18',
 7         'USER':'root',
 8         'PASSWORD':'',
 9         'HOST':'localhost',
10         'PORT':3306,
11     }
12 }

In the application configuration file of the same name __inti__.py

 

import pymysql
pymysql.install_as_MySQLdb()

Guess you like

Origin www.cnblogs.com/kogmaw/p/12452729.html