python
runtime_error
ai_generated
true
配置错误:接收器必须是可调用对象或可调用对象元组
django.core.exceptions.ImproperlyConfigured: Receiver must be a callable or a tuple of callables.
ID: python/django-signal-receiver-error
80%修复率
84%置信度
0证据数
2024-04-29首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
在connect()方法中传入的不是函数或可调用对象
English
信号连接时传递了非函数对象
解决方案
-
95% 成功率
from django.db.models.signals import post_save; post_save.connect(my_handler)
-
90% 成功率
from django.dispatch import receiver; @receiver(post_save, sender=MyModel)
无效尝试
常见但无效的做法:
-
90% 失败
Django不支持字符串引用,必须是实际函数
-
80% 失败
信号不会触发,功能缺失