Reputation: 228
I've used Django signals in the past. I'm working on a 1.10 app now, and for some reason I cannot get my receiver to be called.
app1/signals.py
from django.dispatch import Signal
list_member_updated = Signal(providing_args=['list_member_id',])
app1/models.py
print('Dispatching signal...')
list_member_updated.send(self.__class__, list_member_id=list_member.id)
app1/apps.py
class DjangoApp1Config(AppConfig):
name = 'app1'
def ready(self):
import app1.signals
app2/util.py
from django.dispatch import receiver
from app1.signals import list_member_updated
@receiver(list_member_updated)
def handle_member_updated(sender, **kwargs):
print('Received signal')
So I get the "Signal dispatched..." in the console, but not the "Received signal". I have a feeling I'm missing something simple, but I just cannot see it.
Upvotes: 0
Views: 983
Reputation: 1956
In app1/__init__.py add the mentioned line. it worked for me
default_app_config = 'app1.apps.DjangoApp1Config'
Note: The app1/__init__.py bits are not required if you are already referring to your AppConfig in the INSTALLED_APPS settings.
You can refer to this for more details.
Upvotes: 2