django 存储数据时 报 IntergrityErrror错误

Django saves the data but eventually raises an IntegrityError. Django中保存的数据,但最终引发一个IntegrityError。 If there is an error, why it is saving that data?如果有一个错误,为什么它被保存的数据? And I'm sure that the uniqueness property is not violated on that data.而且我敢肯定,没有违反该数据的唯一性。

What is going on?这是怎么回事呢? Why is that error occurs?这是为什么发生错误?and how can I solve that?我怎样才能解决这个问题呢?

  • Most likely your model has a field which doesn't allow null value and you are trying to add object without any value for that field.最有可能你的模型中有一个字段不允许空值,您尝试添加该字段的值没有任何对象。

    If you can Edit your post and add more details (like model & traceback) then you can expect better response.如果您可以编辑您的文章和添加更多的细节(如模型及追踪),那么你可以期待更好的响应。

  • I had the same problem.我有同样的问题。 Using Django 1.3.1 and Sqlite3, I had changed the field properties setting blank=True and null=True, but still got the IntegrityError: "Field may not be null".使用Django 1.3.1和SQLite3,我改变了空白= True和空的字段属性设置为True,但仍然有IntegrityError:“字段不能为空”。 I tried successive python manage.py syncdb andpython manage.py sqlflush with no luck.我试过连续python manage.py syncdbpython manage.py sqlflush没有运气。

    I solved it creating a new DB (that is, changing the path to a non-existent filename), and then everything was perfect.我解决它创建一个新的数据库(即,改变路径到一个不存在的文件名),然后一切都很完美。 Obviously, existing data migration is an issue.显然,现有的数据迁移是一个问题。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值