DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'books', #你的数据库名称
'USER': 'root', #你的数据库用户名
'PASSWORD': '', #你的数据库密码
'HOST': '', #你的数据库主机,留空默认为localhost
'PORT': '3306', #你的数据库端口
}
}
因为是mysql数据库 所有要在 项目下的 init.py 下加
import pymysql pymysql.install_as_MySQLdb()
在Django2.0以后 你就会报一个错
......
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__) django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
我们要在源码中注释
路径 E:xxxxxxxxLibsite-packagesdjangodbackendsmysqlase.py

但是在启动 还有一个报错
File "E:project_luffyluffylibsite-packagesdjangodbackendsmysqloperations.py", line 146, in last_executed_query
query = query.decode(errors='replace')
AttributeError: 'str' object has no attribute 'decode'
点击146行 修改源码 添加一句
