@ transaction.atomic不能处理signals.py

时间:2017-10-13 08:18:55

标签: python django postgresql django-models

这是我的signals.py文件

@transaction.atomic
def post_save_transaction(sender, instance, created, **kwargs):
    """
    adjusts the patient or organization account balance on transaction
    """
    if created:
        instance.paid_by.balance -= instance.amount
        instance.accounts.balance += instance.amount
        instance.accounts.save(update_fields=['balance'])
        instance.paid_by.save(update_fields=['balance'])

此事务一次创建多个对象,但它再次使用之前的余额。

0 个答案:

没有答案