I read the django docs
about signals
and wrote this piece of code for my model Car
:
@receiver(request_finished)
def s
There is a simpler way to bind post_save signals
from django.db.models.signals import post_save
from myapp.models import Car
def do_something(sender, **kwargs):
print 'the object is now saved.'
car = kwargs['instance'] #now i have access to the object
post_save.connect(do_something, sender=Car)
The signal request finished gets called every time a HTTP request is made, which is a hog.
You binded request_finished
signal to signal_callback
. Remove(or comment out) signal_callback
, and change signal_handler
as follow.
@receiver(post_save, sender=Car)
def signal_handler(sender, **kwargs):
print 'Save signal received'