My models.py:>
class Aval(models.Model):
cliente = models.ForeignKey(Cliente)
salao = models.ForeignKey(Salao)
rate = models.IntegerField(choices=RATE, default=5)
criacao = models.DateTimeField(blank=True, null=True, auto_now=True)
comentario = models.TextField(max_length=400, blank=True, null=True, default=None)
aprovado = models.BooleanField(default=False)
My signals.py:>
@receiver(post_save, sender=Aval)
def new_rate(sender, instance, created, **kwargs):
aval = instance
print("Aval is saved.")
I'm testing the signal post_save for Aval model, When I'm save some object Aval it not printing "Aval is saved" . What I'm doing wrong ?
Original answer for Django < 1.7:
You should include:
to
__init__.py
file of your application.Edit: Django >= 1.7:
Signals can be registered in
django.apps.AppConfig.ready
as described in Signals documentation andAppConfig
doc