Managing serialization and deserialization

Our RESTful web API has to be able to serialize the game instances into JSON representations and also deserialize the JSON representations to build game instances. With Django REST Framework, we just need to create a serializer class for the game instances to manage serialization to JSON and deserialization from JSON.

Django REST Framework uses a two-phase process for serialization. The serializers are mediators between the model instances and Python primitives. Parsers and renderers act as mediators between Python primitives and HTTP requests and responses.

We will configure our mediator between the Game model instances and Python primitives by creating a subclass of the rest_framework.serializers.Serializer ...

Get Hands-On RESTful Python Web Services - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.