class PO(models.Model)
qty = models.IntegerField(null=True)
cost = models.IntegerField(null=True)
total = qty * cost
How will I solve <
You can make total
a property
field, see the docs
class PO(models.Model)
qty = models.IntegerField(null=True)
cost = models.IntegerField(null=True)
def _get_total(self):
"Returns the total"
return self.qty * self.cost
total = property(_get_total)
Justin Hamades answer
class PO(models.Model)
qty = models.IntegerField(null=True)
cost = models.IntegerField(null=True)
@property
def total(self):
return self.qty * self.cost