I tested the "pre_save" signal of Django in the following ways, but cannot catch the signal in either of them.
$
from django.db.models.signals import pre_save
import logging
def my_callback(sender, **kwargs):
logging.debug("======================================")
pre_save.connect(my_callback)
Run the above code in manage.py shell: Then I run my website and see models.save() work successfully, but the callback function does not run.
Alternatively, I run the above code on shell again and then run models.save() in the shell. "save" works well again but still nothing happens to the callback function.
Finally, I embed the above code in an
__init__.py
file and still, run the save() function on the website. Still, nothing occurs.
Would you please help me figure out why pre_save signal seems not work?