我具有不运行定制连接的信号:在竞赛模型的方法中add_participantDjango自定义连接信号发送但方法不运行..如何解决?
代码:
# this is called and no error happens
contest_after_added_participant.send(sender=self,
participant=participant,
participation=participation)
代码文件中的该竞赛模型存在:
def my_callback(sender, **kwargs):
sender.title += 'sss' # this is never called
contest_after_added_participant = Signal(providing_args=["participant", "participation"])
contest_after_added_participant.connect(my_callback, sender=Contest, dispatch_uid='Contest.001')
谢谢,我会试试看。然后我认为这个文档有问题:https://docs.djangoproject.com/en/dev/topics/signals/#connecting-to-signals-sent-by-specific-senders - “pizza_done.send(sender = self,toppings = toppings,size = size)“;他们正在发送一个实例。 –
您可以使用实例作为发送者发送信号,但在这种情况下,信号应连接到实例。是的,你的权利,他们没有显示任何信号使用的完整例子。 – Ilya