【问题标题】:django fixtures loaddatadjango 夹具加载数据
【发布时间】:2015-01-01 11:14:24
【问题描述】:

我需要运行一个已经存在的 django 项目。

我安装了所有依赖项,运行了 syncdb,migrate。现在应用程序运行良好。但我想加载夹具,以便我可以使用示例数据测试应用程序。

我有三个文件 fixtures/first.json /fixtures/thing.yaml fixtures/good_email.yaml

当我运行 ./manage.py loaddata fixtures/good_email.yaml 时出现此错误。

IntegrityError: Problem installing fixture 'fixtures/good_email.yaml': Could not load
Myproject.MYclass(pk=78): columns kabal_id, email are not unique

我该如何解决这个问题,我不想重新生成灯具,但我需要对我的灯具进行一些修复。

【问题讨论】:

    标签: python django


    【解决方案1】:

    您有两个字段的唯一约束,但要导入的数据会违反此约束(双值)。您必须将数据更改为唯一的才能删除违规记录。

    【讨论】:

    • 我检查了修复文件,文件但无法找到该行,因为有 20000 行。请帮忙
    • pk (78) 为您提供了查看哪条线的指标。我不知道这些文件,所以我不能告诉你更多。
    • 好的,谢谢,有没有加载夹具文件的顺序?
    猜你喜欢
    • 2011-06-07
    • 2013-03-06
    • 1970-01-01
    • 2014-08-16
    • 2023-03-03
    • 2011-03-10
    • 1970-01-01
    • 2010-11-30
    • 2012-02-24
    相关资源
    最近更新 更多