I have a quick question. I am trying to add a field to a model, which is a sum of two fields.
For instance:
class MyModel(models.Model)
fee = models.DecimalField()
fee_gst = models.DecimalField()
I thought I could just add @staticmethod inside the model:
@staticmethod
def fee_total(self):
return self.fee + self.fee_gst
But I can’t access the "fee_total" field of the model using:
model = MyModel.objects.get(pk=1)
total = model.fee_total
Any ideas what I'm doing wrong?
Greetings
source
share