DRF source code analysis - serialization

First, serialization

1, the basic knowledge of class:

The method is executed prior to the process __new__ class instantiation, for generating a controlling instance of the class to generate a null object subclass __new__ went no parent class,

__new__ to perform __init__ constructor After executing

2, an example ModelSerializer, no __new__ method Serlizer no parent class, looking up at the __new__ method BaseSerlizer
instance there is a sequence of values

data has a value that is deserialized

After executing the performing the __init__ __new__, constructed in accordance with the value of many different execution of,

3, the processing performed when cls.many_init Methods LIstSerializer when many = True, then our object data property of the object acquisition result (res.data)

4, the parent data source method BaseSerlize properties:

Second, check data

The global verification: validate

Partial checksum: validate_ partial checksum field name

Source code analysis

1, only to go check before calling the is_valid

Guess you like

Origin www.cnblogs.com/king-home/p/11134839.html