Django update queryset with annotation

前端 未结 6 555
梦谈多话
梦谈多话 2020-12-24 01:06

I want to update all rows in queryset by using annotated value.

I have a simple models:

class Relation(models.Model):
    rating = models.IntegerFiel         


        
6条回答
  •  礼貌的吻别
    2020-12-24 01:46

    If you want to avoid many calls to the database, you should use transaction.atomic.

    Read more on Django documentation: https://docs.djangoproject.com/en/1.9/topics/db/transactions/#controlling-transactions-explicitly

提交回复
热议问题