Request
1. Django's request.POST only gives you support for POST requests with form encoded data. If
you want to handle JSON, or if you want to make PUT and PATCH requests, then REST
framework's request.data is what you want, yes.
DRF:
Serilizer
1. is_valid() method:
a. This method is written in base serializer
b.
c. This method first check that initial data must be available but validated data should
not be available.
d. After checking this it goes for run_validation method over the available initial data.
2. run_validation () method
a. it is implemented in the serializer class.
b.
c. This method first checks that initial data must not be empty.
d. It in all goes through three methods
e. { ‘ to_internal_value ‘ : “ it checks all field level validation,
f. ‘ run_validator ‘ : “it checks for all defaults,
g. ‘ validator ‘: “it checks for all validation function made for object level validation”
h. }
i. Then it runs the to_internal_value method which is also implemented in the serializer
class.
j.
k.
l. In this method we go field by field.
m. For each field we check for validate_method which is explained at the link below
n. https://www.django-rest-framework.org/api-guide/serializers/#field-level-validation
o.
p. After checking for all field level validate method we apply run_validator which applies
all default value to the field.
q. And finally we pass all these value through .validate() method which we can define in
the serializer class (object level validation)
r.
s. Other object level validations are shown below:
t.
u.