3๐
โ
As of django 1.4, you can make use of a bulk_create
method to create numerous B objects in one go, then add them to the A.b ManyToMany
So create a list of B
objects, bulk create them, then add them (all at once) to the ManyToMany
relationship of your A
instance(s):
l = [
B(...),
B(...),
B(...),
...
]
B.objects.bulk_create(l)
a.b.add(*o)
๐คTimmy O'Mahony
Source:stackexchange.com