[Answered ]-Django Rest Frame API: additional fields in ModelSerializer

2👍

As you have not posted any code I can only give you a generic answer, but if I understand you correctly, you wish to add a custom field to a ModelSerializer thats not part of your model…

In DSF you can do this very esaily (read here):

In this case you just want a simple read-only field, so instead just use:

custom_field = Field(source='get_whatever')

In terms if validation after that please read the DRF guide here

Leave a comment