I'm trying to receive the user_activated signal sent by django-registration when a user account is activated. Here is my signals.py
当用户帐户被激活时,我正在尝试接收由django-registration发送的user_activated信号。这是我signals.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')
But when a user is activated the user_activated signal is sent twice. I know this because the output is
但是当用户被激活时,user_activated信号会被发送两次。我知道这个,因为输出是
received signal
received signal
Multiple imports of signals.py shouldn't connect the signal receiver twice because I use a unique dispatch_uid, so why is the signal sent twice? Is it a problem with my code or a problem with django-registration (using the default backend)?
多个信号的进口。py不应该连接两次信号接收器,因为我使用唯一的dispatch_uid,那么为什么信号要发送两次呢?这是我的代码的问题还是django注册的问题(使用默认后端)?
1 个解决方案
#1
1
The dispatch_uid
just stops you from connecting to the same signal twice, but the problem is thatdjango-registration
SENDS OUT the signal twice.
dispatch_uid只会阻止您连接到同一个信号两次,但问题是django-registration会发送两次信号。
To fix it, apply this patch to registration/views.py
and it should work.
要修复它,请将此补丁应用到注册/视图。py和它应该起作用。
#1
1
The dispatch_uid
just stops you from connecting to the same signal twice, but the problem is thatdjango-registration
SENDS OUT the signal twice.
dispatch_uid只会阻止您连接到同一个信号两次,但问题是django-registration会发送两次信号。
To fix it, apply this patch to registration/views.py
and it should work.
要修复它,请将此补丁应用到注册/视图。py和它应该起作用。