1, All in all : Give you the data , According to what format , Call it a parser
django In fact, it also comes with a parser , Like that one. JsonResponse() It will return json Class
We use restframework The parser , As long as in the overall situation settings.py For a long time , It does not need to be set separately in the specific views In the middle , That's all right. , as follows :
REST_FRAMEWORK = {
'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.URLPathVersioning', # Version class settings
'DEFAULT_VERSION': 'V1', # Default version
'DEFAULT_VERSIONS': ['V1', 'V2'], # The default version set
'DEFAULT_PARSER_CLASSES': ['rest_framework.parsers.JSONParser','rest_framework.parsers.FormParser'] # Set the path of the parser
}