django create bulk code example
Example 1: how to save bulk create in django
def builtin():
insert_list = []
for i in range(10000):
name="String number %s" %i
insert_list.append(Record(name=name))
Record.objects.bulk_create(insert_list)
Example 2: bulk create django
bulk_create(objs, batch_size = None, ignore_conflicts = False)
Entry.objects.bulk_create([
... Entry(headline='This is a test'),
... Entry(headline='This is only a test'),
... ])
Example 3: django insert bulk data
Entry.objects.bulk_create([
Entry(headline = "foo"),
Entry(headline = "bar")
])