Is django's bulk_create atomic?

Viewed 639

Will Django rolls back changes if there is any failure while batch creation of objects using bulk_create() in django? Or should I explicitly use transaction.atomic()?

I have Foreignkey references in my models which might not be present in database.

I'm using Django 1.11

1 Answers

bulk_create() produces single query if there is no batch_size set ( except for SQLite where batch is 999)

You should do transaction.atomic() block only if you set batch_size and you want all previous batches to be reverted

Related