Our RESTful Web Service has to be able to serialize and deserialize the
Toy instances into JSON representations. In Django REST framework, we just need to create a serializer class for the
Toy instances to manage serialization to JSON and deserialization from JSON. Now, we will dive deep into the serialization and deserialization process in Django REST framework. It is very important to understand how it works because it is one of the most important components for all the RESTful Web Services we will build.
Django REST framework uses a two-phase process for serialization. The serializers are mediators between the model instances and Python primitives. Parser and renderers handle as mediators between Python primitives and HTTP requests and responses. We will configure our mediator between the
Toy model instances and Python primitives by creating a subclass of the
rest_framework.serializers.Serializer class to declare the fields and the necessary...