django temporarily disable signals

前端 未结 2 693
情歌与酒
情歌与酒 2021-02-07 07:41

I have a signal callback in django:

@receiver(post_save, sender=MediumCategory)
def update_category_descendants(sender, **kwargs):
    
    def children_for(categ         


        
2条回答
  •  我在风中等你
    2021-02-07 08:13

    Perhaps I'm wrong, but I think that category.save() is not needed in your code, add() is enough because change is made in descendant but in category.

    Also, to avoid signals you can:

    • Disconnect signal and reconnect.
    • Use update: Descendant.objects.filter( pk = descendant.pk ).update( category = category )

提交回复
热议问题