Django开发管理系统使用问题汇总

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值