Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to list Django signals?

Tags:

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

like image 226
interstar Avatar asked Jul 06 '09 15:07

interstar


People also ask

What are the signals in Django?

Django includes a “signal dispatcher” which helps decoupled applications get notified when actions occur elsewhere in the framework. In a nutshell, signals allow certain senders to notify a set of receivers that some action has taken place.

Where is Pre_save signal in Django?

pre_save. This is sent at the beginning of a model's save() method. Arguments sent with this signal: sender.

Should I use signals Django?

Only use signals to avoid introducing circular dependencies. If you have two apps, and one app wants to trigger behaviour in an app it already knows about, don't use signals. The app should just import the function it needs and call it directly.

What is Post_save in Django?

In the example above, save_profile is our receiver function, User is the sender and post_save is the signal. You can read it as: Everytime when a User instance finalize the execution of its save method, the save_profile function will be executed. If you supress the sender argument like this: post_save.


1 Answers

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 
like image 153
kibitzer Avatar answered Oct 05 '22 02:10

kibitzer