Django signal emitting once, received twice — Why?

后端 未结 2 869
名媛妹妹
名媛妹妹 2021-02-02 14:27

I\'m working with Django signals, but they seem to be received twice, even if emitted once. Here\'s the code I\'m working with (it\'s a simple wrapper to use Uploadify with Dja

2条回答
  •  感情败类
    2021-02-02 15:00

    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

提交回复
热议问题