django signal post_save is not working while debug is false
Asked Answered
E

0

2

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())

FYI - I'm using django 3.2.4

Eskimoaleut answered 18/10, 2021 at 17:25 Comment(5)
check, #69003696Fuss
Thanks @Fuss for your recommendation link, as per the post I've upgraded psycopg2-binary version but nothing changed. Still the same error. Any other suggestion?Eskimoaleut
check: https://mcmap.net/q/225988/-django-signal-only-works-when-debug-true-django-3-2-4Jessalyn
have you found anything? @EskimoaleutBalch
yes, user weak=False and that works perfectly. I've used in this line: @receiver(post_save, sender=PackageSubscription, weak=False) Let me know if you need any help.Eskimoaleut

© 2022 - 2024 — McMap. All rights reserved.