1. mysqlclient 1.3.13 or newer is required; you have 0.9.3.
使用pip install pymysql
后,一运行就提示该错误,但是明明已经是最新的了,这就让人很迷了。
后来去找了一下,发现原来是python 3.6版本的pymysql就没有更新的版本,解决办法就把该异常判断给去掉。
找到Python安装路劲下的Python36-32\Lib\site-packages\django\db\backends\mysql\base.py
文件;
将文件中的如下代码注释
if version < (1, 3, 3):
raise ImproperlyConfigured("mysqlclient 1.3.3 or newer is required; you have %s" % Database.__version__)
搞定。
参考:django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.7.11
2. str has no attribute decode
python 版本不对
查看python版本,cmd–python — import django—django.get_version()
卸载原有版本
重装特定版本
pip install django==2.1.7
2. 在创建customer_info表执行 Hive 2 Mysql 时,出现WARN: Establishing SSL connection without server's identity verification is not recommended
.
参考来源:
MYSQL:WARN: Establishing SSL connection without server’s identity verification is not recommended.
MySQL Establishing SSL connection without server’s identity verification warning
可能原因:是有字段数据类型不对,但至今未解决!!!
3. 提示ImproperlyConfigured: Field name “xx” is not valid for model “xxx”
参考来源:Django-Rest-Framework 3.0 Field name ‘’ is not valid for model ModelBase
4. Django Models (1054, “Unknown column in ‘field list’”)
5.使用ForeingKey时,报错model.field_id xxx
- 原因:在多对一的情况下,使用外键关联取不到数据,不用外键,
回头细讲
- 解决办法:
users = serializers.SerializerMethodField(method_name="getusers")
def getusers(self,obj):
id = obj.user_id
users = User.objects.filter(id=id)
if users is not None and len(users) == 1:
return UserSerializer(users[0],many=False).data
else:
return None