[Fixed]-Updating a field in table A only by insert operation in table B

1👍

I think you can use django post_save
see this https://docs.djangoproject.com/en/1.9/ref/signals/#post-save

Update your models.py with the below codes

def update_money(sender, instance, created, **kwargs):
    if created:
       gate = Gateway.objects.get(id = instance.gate_id )
       gate.money = gate.money +  transaction.amount 
       gate.save()        


signals.post_save.connect(update_money, sender=Transactions)
👤Anoop

Leave a comment