Simple use of Django REST framework, djangoframework
See https://github.com/linux-wang/DRF_tutorial/blob/master/README.md for details
DRF has a serializer concept. The function is to convert various Django Queryset and model instances to Python native formats, saving the type problems you face when writing APIs, you can also perform reverse operations. The official documentation is as follows:
Serializers allow complex data such as querysets and model instances to be converted to native Python PES ypes that can then be easily renderedJSON
,XML
Or other content types. Serializers also provide deserialization, allowing parsed data to be converted back into complex types, after first validating the incoming data.
The serializers in REST framework work very similarly to Django'sForm
AndModelForm
Classes. We provideSerializer
Class which gives you a powerful, generic way to control the output of your responses, as well asModelSerializer
Class which provides a useful shortcut cut for creating serializers that deal with model instances and querysets.