我正在阅读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.
"
Run Code Online (Sandbox Code Playgroud)
我没有完全理解它.所以,如果我有一个对象列表,请将其传递给bulk_create:
objList = [a, b, c,] #none are saved
model.objects.bulk_create(objList)
Run Code Online (Sandbox Code Playgroud)
我还能在外键中使用这些对象吗?
for obj in objList: …Run Code Online (Sandbox Code Playgroud)