December 2018
Beginner to intermediate
796 pages
19h 54m
English
We created the toy model (the Toy class) and its serializer (the ToySerializer class). When we wrote the code for the ToySerializer class, we had to declare many attributes with the same names that we used in the Toy class. The ToySerializer class is a subclass of the rest_framework.serializers.Serializer superclass; it declares attributes that we manually mapped to the appropriate types, and overrides the create and update methods. However, we repeated a lot of code and information that was already included in the toy model, such as the types and the max_length values that specify the maximum length for each string field.
Now, we will take advantage of model serializers to simplify code and to avoid ...
Read now
Unlock full access