Django数据同步过程中遇到的问题:
1. 使用pip install PyMySQL安装PyMySQL,安装完成后在setting.py文件同级目录的__init__.py增加以下代码:
import pymysql
pymysql.install_as_MySQLdb()
2. 运行python mansge.py runserver失败,错误提示:
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.
解决办法:在C:\python\Lib\site-packages\django\db\backends\mysql(python安装目录)打开base.py,注释掉以下内容:
if version < (1, 3, 13):
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
3. File "C:\python\Lib\site-packages\django\db\backends\mysql\operations.py", line 146, in last_executed_query
query = query.decode(errors='replace')
AttributeError: 'str' object has no attribute 'decode'
解决办法:打开此文件把146行的decode修改为encode
4.报错:
SystemCheckError: System check identified some issues:
ERRORS:
<class 'webtest.admin.WebcaseAdmin'>: (admin.E108) The value of 'list_display[1]' refers to 'webtestresult', which is not a callable, an attribute of 'WebcaseAdmin', or an attribute or method on 'webtest.Webcase'.
原因:迁移数据库没有对应字段导致报错
解决办法:检查对应的admin文件和models文件查看字段是否对应,特别注意的还需要检查缩进