bulk update in django in django 3.1 code example
Example 1: django bulk update
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'])
Example 2: django bulk update
objs = []
for person in p:
obj = People.objects.get(email=person['email'])
obj.birthday = person['birthday']
objs.append(obj)
People.objects.bulk_update(objs, ['birthday'], batch_size=1000)