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%Fix Rate
84%Confidence
0Evidence
2024-04-29First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
信号连接时传递了非函数对象
generic中文
在connect()方法中传入的不是函数或可调用对象
Workarounds
-
95% success
from django.db.models.signals import post_save; post_save.connect(my_handler)
-
90% success
from django.dispatch import receiver; @receiver(post_save, sender=MyModel)
Dead Ends
Common approaches that don't work:
-
90% fail
Django不支持字符串引用,必须是实际函数
-
80% fail
信号不会触发,功能缺失