Skip to content
Advertisement

Update Query list in Django

I’m having a trouble on how can I automatically update my amount_unpaid when the time I updated my amount_paidcolumn. The result of amount_unpaid should be subtract my amountamount_paid = amount_unpaid . The way I updated my data is using list like the code below, please check this out, Any help is much appreciated Thanks in advance.

AttributeError: ‘QuerySet’ object has no attribute ‘amount’

enter image description here

JavaScript

Advertisement

Answer

I think the minimalist solution is:

JavaScript

I am using F(<field_name>) to get the value of the field from that object. Hence I do not need a for loop.

For more information, please see the documentation on update(...) and F().

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement