Understanding the basics of DRF Serializers
In the previous chapter, we learned how to use databases using Django models and ORM. However, in the world of web applications, the interaction between the client and server happens using REST APIs, with the JSON request-response format. Let us see how a client-server API interaction looks.
A client application uses the JSON data format to send information to the server via a ReST API. A Django server running on DRF uses, by default, JSONParser to parse the data from the JSON format to the Python native format. Then, data in the Python native format would be passed to a serializer to save the data in the Database, using the Django ORM. Similarly, when data is retrieved from the database using the Django ORM, it will be passed through a Serializer to deserialize the data into the Python native format. The Python native format data would be passed through JSONRenderer to render the data into the JSON format, finally sending a response to...