Tag Archives: Django Rest Framework

Django Rest Framework – Change returned fields in serializers.ModelSerializer

Model Serializers has it's built in advantages where it's easy to implement and you are happy with the naming convention of the table fields. What if you are not and need to customize the field names.

Scenario 1.

A GET web service call returns the following json string:

but I want to return the following json:

Here's the code to do it in serializers.py:

And here's what's in the api.py

Hope this helps someone.

Thanks for reading.