[Fixed]-Django signal emitting once, received twice — Why?

22👍

This has happened to me before and it was due to the module where you are connecting the signal being imported twice. To make sure the signal isn’t connected twice you can set the dispatch_uid:

upload_recieved.connect(upload_received_handler, dispatch_uid="some.unique.string.id")

UPDATE
It is actually documented here: http://code.djangoproject.com/wiki/Signals#Helppost_saveseemstobeemittedtwiceforeachsave

👤Ricky

1👍

you can check "created" argument in your function that you are connecting with signal which returns True and False respectively. Created will be True only when a new object is created.

def task_feedback_status_handler(sender, instance, created, **kwargs):
    if created:
        do something
post_save.connect(task_feedback_status_handler, sender=Feedback)

Leave a comment