Django | QuerySet API reference | Django documentation

Django | QuerySet API reference | Django documentation

bulk_create

bulk_create(objs)
New in Django 1.4: Please see the release notes

This method inserts the provided list of objects into the database in an
efficient manner (generally only 1 query, no matter how many objects there
are):

>>> Entry.objects.bulk_create([
...     Entry(headline="Django 1.0 Released"),
...     Entry(headline="Django 1.1 Announced"),
...     Entry(headline="Breaking: Django is awesome")
... ])

This has a number of caveats though:

    原文地址:https://www.cnblogs.com/lexus/p/2466592.html