8.序列化 功能: 对请求数据进行验证 对Queryset进行序列化 8.1一个简单序列化: import json from api import models from rest_framework import serializers class RolesSerializer(serializers.Serializer): title = serializers.CharField() class RolesView(APIView): def get(self,request,*ar…
一.第一版(一般不用) # 声明序列化器from rest_framework import serializersfrom djangoDome.models import Book class PublisherSerializer(serializers.Serializer): id = serializers.IntegerField() title = serializers.CharField(max_length=32) class AuthorSerializer(serial…