我正在阅读 Django bulk_create 及其一些“缺陷”:
"
This has a number of caveats though:
1. The model's save() method will not be called, and the pre_save and post_save signals will not be sent.
2. It does not work with child models in a multi-table inheritance scenario.
3. If the model's primary key is an AutoField it does not retrieve and set the primary key attribute, as save() does.
"
我没有完全理解。因此,如果我有一个对象列表,请将其传递给 bulk_create:
objList = [a, b, c,] #none are saved
model.objects.bulk_create(objList)
我还能在外键中使用这些对象吗?
for obj in objList:
o = otherModel(something='asdfasdf', fkey=obj)
o.save() # will this be fine given the caveats stated above?
那么foreignKey关系会好吗?同样当它说2时。它不适用于多表继承场景中的子模型,这意味着任何从另一个模型(抽象或非抽象)继承的模型都不能使用bulk_create?