Я читал о 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?