感谢alex和武沛齐老师 rest_framework中的序列化表示 from rest_framework import serializersclass RoleSerializer(serializers.Serializer): id = serializers.IntegerField() title = serializers.CharField() class RolesView(APIView): def get(self, request, *args, **kwargs):…
序列化组件 from rest_framework.response import Response1.Response本质也是继承了httpresponse,比httpResponse还强大,传入一个字典,列表可以序列化2.会根据不同的请求客户端,返回不同的东西,如果是浏览器访问的话就返回一个页面,如果是手机端的话就返回数据 from django.db import models # Create your models here. class Book(models.Model): nid…
# 序列化设置 class PagerSerialiser(serializers.ModelSerializer): name = serializers.CharField(source="society.name") is_pass =serializers.CharField() class Meta: model = models.SocietyAndUser fields = "__all__" class Society(APIView): def g…
#rest_framework 序列化 from rest_framework import serializers #serilizers.Serializer serializers.ModelSerializer 两种序列化方式 class RolesSerializer(serializers.Serializer): id = serializers.IntegerField() title = serializers.CharField() class RolesView(APIVi…