一、报错信息:

ERROR 2019-04-22 02:00:29,971 exceptions 30 [<wechat.views.WixinView object at 0x7f3bb01dae48>] (1062, "Duplicate entry '余生' for key 'username'")

 

二、错误分析

因为我项目里面用户表继承的是django自带的AbstractUser类,该类的username字段设置为unique=True表示该字段不能重复。

所以当我保存有重复名字的用户时,出现报错

 

三、解决方法

将unique=True注释,unique不指明为True时,默认为False

将数据库的username字段唯一性删除drop index username on tb_users;

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-05
  • 2021-06-18
  • 2021-09-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
  • 2021-04-29
  • 2021-08-19
  • 2021-12-17
相关资源
相似解决方案