这是我的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'])
此事务一次创建多个对象,但它再次使用之前的余额。