bulk_operations.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:djangolab 作者: DhiaTN 项目源码 文件源码
def update_list_best_practice():
    """
    Hits the DB once no matter how many objects.
    NB:
      - save() will not be called, and the related signals will not be sent.
      - does not work with m2m relationships.

    >>> UPDATE community SET name = (community.name + ' e.V')
        WHERE community.name LIKE 'community%'
    """
    communities = Community.objects.filter(name__startswith='community')
    communities.update(name=Concat('name', Value(' e.V')))


## Bulk delete
##############
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号