Is there a way to list Django signals?

前端 未结 4 476
面向向阳花
面向向阳花 2021-02-04 00:48

Is there a way to see which signals have been set in Django?

4条回答
  •  既然无缘
    2021-02-04 01:07

    It's not really exposed in docs but Signal is just a class that contains a list of receivers which are called on event. You can manually check this list:

    from django.db.models.signals import *
    
    for signal in [pre_save, pre_init, pre_delete, post_save, post_delete, post_init, post_syncdb]:
        # print a List of connected listeners
        print signal.receivers
    

提交回复
热议问题