After setting up REST framework, we need to specify how our data will be serialized. Output data has to be serialized in a specific format, and input data will be de-serialized for processing. The framework provides the following classes to build serializers for single objects:
- Serializer: Provides serialization for normal Python class instances
- ModelSerializer: Provides serialization for model instances
- HyperlinkedModelSerializer: The same as ModelSerializer, but it represents object relationships with links rather than primary keys
Let's build our first serializer. Create the following file structure inside the courses application directory:
api/ __init__.py serializers.py
We will build all the API functionality inside ...