3

当用户帐户被激活时,我正在尝试接收 django-registration 发送的 user_activated 信号。这是我的信号.py

from registration.signals import user_activated

def receiver(sender, user, request, **kwargs):
    print 'received signal'

user_activated.connect(receiver, dispatch_uid='registration.signals.user_activated')

但是当用户被激活时, user_activated 信号被发送两次。我知道这是因为输出是

received signal
received signal

多次导入signals.py不应该连接信号接收器两次,因为我使用了唯一的dispatch_uid,那为什么信号会发送两次呢?是我的代码有问题还是 django-registration 有问题(使用默认后端)?

4

1 回答 1

1

dispatch_uid只是阻止您两次连接到同一信号,但问题是django-registration两次发送信号。

要修复它,请应用补丁registration/views.py,它应该可以工作。

于 2013-09-20T03:22:39.373 回答