Search code examples
djangodjango-signals

django signals received by only one function


I have a model that sends signal:

class WMTransaction(models.Model):
    def save(self, *args, **kwargs):
        if self.status == 'completed':
            self.completed = datetime.datetime.now()
            try:
                old = WMTransaction.objects.get(pk=self.pk)
                if old.status == 'processing':
                    print 'sending signal'
                    payment_done.send(self)
            except:
                pass
        super(WMTransaction, self).save(*args, **kwargs)

Also I have receivers in 2 modules:

@receiver(payment_done, dispatch_uid="make_this_signal_unique", weak=False)
def subscribe(sender, **kwargs):
    print 'subscribing'
    # processing

And:

@receiver(payment_done, dispatch_uid="this_signal_is_also_unique", weak=False)
def buy(sender, **kwargs):
    print 'buying'
    # processing

The problem is that subscribe function is called, and buy - isn't... Both modules are in installed apps, other functions from these modules work correctly. What's the problem with signals?


Solution

  • Has module_B been installed and the definition of buy actually gets executed? Check payment_done.receivers before the payment_done.send line.