1.

What are Django Signals?

Answer»

Whenever there is a modification in a model, we may need to TRIGGER some actions. 
Django PROVIDES an elegant way to handle these in the form of signals. The signals are the utilities that allow us to associate events with actions. We can implement these by developing a function that will run when a signal calls it.

List of built-in signals in the models:

SignalsDescription
django.db.models.pre_init &
django.db.models.post_init
Sent before or after a models’s _init_() method is called
django.db.models.signals.pre_save & django.db.models.signals.post_saveSent before or after a model’s save() method is called
django.db.models.signals.pre_delete &
django.db.models.signals.post_delete
Sent before or after a models’ delete() method or queryset delete() method is called
django.db.models.signals.m2m_changedSent when a ManyToManyField is changed
django.core.signals.request_started &
django.core.signals.request_finished
Sent when an HTTP REQUEST is STARTED or finished


Discussion

No Comment Found