I had a problem with post_save
being called twice and I spent a lot of time figuring out the imports as had been mentioned. I confirmed that the import is happening only once and there is no question of multiple registrations. Besides I'm using a unique dispatch_uid
in the signal registration which as per the documentation should have solved the problem. It did not. I looked more carefully and saw that the signal handler gets called on .create() as well as .save(). Why for create?
The only way I could get it to work is by relying on the hack below inside my signal handler
created = False
#Workaround to signal being emitted twice on create and save
if 'created' in kwargs:
if kwargs['created']:
created=True
#If signal is from object creation, return
if created:
return
This is a follow up to question Django post save signal getting called twice despite uid