django bulk create from list code example

Example 1: bulk create django

bulk_create(objs, batch_size = None, ignore_conflicts = False)

#eg
Entry.objects.bulk_create([
...     Entry(headline='This is a test'),
...     Entry(headline='This is only a test'),
... ])
# inserts in one query (usually), caveats below:
# doesn't signal pre_save and post_save 
# cant use child models
# no many-to-many
# obj list fully evaluates if objs is a generator

Example 2: bulk upload with dictionary or list in django moels

values = [{headline="abc"}, {headline="def"}, {headline="ghi"}]
aList = [Entry(**vals) for vals in values]