I'm using Django 2.x
I have a model like
class MyModel(models.Model):
name = models.CharField()
balance = models.IntegerField()
I want to change the value of balance on the GET request without changing the value in the database.
Like if it could be @Property field, the model will look like
class MyModel(models.Model):
name = models.CharField()
balance = models.IntegerField()
@property
def balance(self):
if balance:
return balance
return 0.15 * 50
But redeclaration is not allowed. How can I solve this issue?
Note: Field should be compatible with ModelAdmin and DRF Serializer