我正在编写一个小的django命令,将数据从json API端点复制到Django数据库中。在我实际创建对象的时候,使用obj, created = model.objects.get_or_create(**filters)时,我得到了一个MultipleObjectsReturned错误。这让我很惊讶,因为我对get_or_create的理解是,如果我试图创建一个已经存在的对象,它会直接“获取”它。我不确定我正在克隆的数据库的完整性,但即使其中有多个相同的<
#auto_now_add=True was the problem
unique_together = ('numeric','date')如果已经存储了date='2011-08-07')django.db.utils.IntegrityError: (1062, "Duplicate entry '72-2011-08-07'
问题是为什么get_or_create会提出IntegrityError,这
True) class Meta:
unique_togethermultiple user so I'm making name and str together as a unique key but I dont know how to use it here with get_or_create#right now (without using unique_toge