在我们将创建好的模型类映射到数据库,以及将我们映射的数据表真正在数据库中创建的对应的表时,有可能会遇到如下问题。
第一个问题:install pymysql之后,忘记在项目的__init__.py文件中import pymysql
解决方案:在项目的__init__.py文件中写入如下图两行代码。
第二个问题:Django2.2版本和pymysql版本不兼容(Django2.2及其以上不直接兼容pymysql)
解决方案:
(1)降低Django版本,降到2.2以下(不包括2.2),降低Django版本方法请点击
(2)修改源码(我不赞成这么做),修改源码方法请点击
(3)不用修改源码的方法(我还没有看懂),请点击
第三个问题:Django2.1 版本不再支持mysql5.5
解决方案:
升级mysql版本