Django signal post_save is not working while debug is false

I've implemented django signals for a model. It's only working fine while debug is True. Any idea how to fix this issue, so that post_save signal works when debug is False in production.

Here is my code in models.py

@receiver(post_save, sender=PackageSubscription)
def update_balance(sender, instance, **kwargs):
    current_balance = Balance.objects.get(user=instance.user)
    last_balance = current_balance.last_balance
    get_package = Package.objects.filter(title=instance.package)
    for i in get_package:
        get_coin = i.coin
    update_current_balance = last_balance + get_coin

    if instance.payment_status is True:
       Balance.objects.filter(user=instance.user).update(last_balance=update_current_balance, updated_at=timezone.now())

Your answer will be highly appreciated.

Happy coding :)

Back to Top