批量插入数据

单条插入autocommit的,每插入一次commit一次;批量是插入完成后一次性commit的,效率相对较高。

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

批量更新

Product.objects.filter(name__contains='name').update(name='new name')

批量删除

EnrollSupplemental.objects.filter(account=account).delete()

[ 编辑 | 历史 ]
最近由“jilili”在“2017-05-17 12:40:43”修改