To do bulk update with Python Django, we can use the bulk_update
method.
For instance, we write
objs = [
Entry.objects.create(headline='Entry 1'),
Entry.objects.create(headline='Entry 2'),
]
objs[0].headline = 'This is entry 1'
objs[1].headline = 'This is entry 2'
Entry.objects.bulk_update(objs, ['headline'])
to create 2 Entry
objects and put them on the objs
list.
And then we call Entry.objects.bulk_update
with objs
and ['headline']
to update the headline
column value of each Entry
entry.