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

前端 未结 3 994
悲&欢浪女
悲&欢浪女 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:03

    Here is the ticket about this issue: Django's signal framework may register listeners more than once #3951. It is now fixed in SVN version of Django.

    The problem is exactly as You said: Your module which registers signal, is loaded couple of times, in some cases by different import paths, thus each imported modules this way are wrongly interpreted by Django as different modules which registers the same signal.

提交回复
热议问题