Why is post_save being raised twice during the save of a Django model?

前端 未结 3 954
悲&欢浪女
悲&欢浪女 2020-12-31 04:17

I am attaching a method to the post_save signal of my Django model. This way I can clear some cached items whenever the model is modified.

The problem I am having i

3条回答
  •  时光说笑
    2020-12-31 05:06

    While looking for the root of this problem, you can use quick workaround to prevent registering signal twice:

    signals.post_save.connect(my_handler, MyModel, dispatch_uid="path.to.this.module")
    

    Source.

提交回复
热议问题