How to save a model without sending a signal?

前端 未结 6 2186
名媛妹妹
名媛妹妹 2021-02-06 23:23

How can I save a model, such that signals arent sent. (post_save and pre_save)

6条回答
  •  一个人的身影
    2021-02-07 00:18

    It's a bit of a hack, but you can do something like this:

    use a unique identifier with a filter and then use the update method of the queryset (which does not trigger the signals)

    user_id = 142187
    User.objects.filter(id=user_id).update(name='tom')
    

提交回复
热议问题