I've written some signals in my Django app that are supposed to send out an email when a particular model instance is created or modified, but the signal receiver function doesn't seem to be responding; at any rate, I'm not getting any emails through (although I have already checked that I'm able to send emails with my current configuration).
Anyhow; I wondered, is it possible to manually send a post_save signal for debugging purposes, rather than trying to trigger it by creating a new model instance each time? Thanks!
To answer directly: No. It's sync.
pre_save. This is sent at the beginning of a model's save() method. Arguments sent with this signal: sender.
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.
Yes. See the documentation:
from django.db.models.signals import post_save instance = MyModel(field='qwerty') post_save.send(MyModel, instance=instance, created=True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With