What are ‘signals’?

Signals are used to take action in response to the modification or creation of a database entry. Its utilities help us to connect events with their action. we can create methods that will run a signal when it is called. For example, as soon as a new user instance is generated in the Database, one might want to create a profile instance. Generally, There are 3 types of signals.

  1. pre_delete/post_delete: This signal is thrown before the remove() method is used to delete a model’s instance.
  2. pre_init/post_init: This signal is thrown before/after instantiating a model (__init__() method)
  3. pre_save/post_save: This signal works before/after the method save().

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *