Configuring serialization and deserialization with relationships
The new RESTful Web Service must be able to serialize the DroneCategory, Drone, Pilot, and Competition instances into JSON representations and vice versa. In this case, we must pay special attention to the relationships between the different models when we create the serializer classes to manage serialization to JSON and deserialization from JSON.
In our last version of the previous RESTful Web Service, we created a subclass of the rest_framework.serializers.ModelSerializer class to make it easier to generate a serializer and reduce boilerplate code. In this case, we will also declare one class that inherits from ModelSerializer. The other three classes will inherit from the rest_framework.serializers.HyperlinkedModelSerializer class.
The HyperlinkedModelSerializer is a type of ModelSerializer that uses hyperlinked relationships instead of primary key relationships, and therefore, it represents the relationships to other model...