from rest_framework.views import APIView from rest_framework.response import Response from apps.goods.models import * from apps.goods.serializers import * class GoodsView(APIView): def get(self, request, *args, **kwargs): goods = Goods.objects.all()[:10] goods_json = GoodsSerializers(goods, many=True) print(goods_json) print(goods_json.data) return Response(goods_json.data) class GoodsModelView(APIView): def get(self, request, *args, **kwargs): goods = Goods.objects.all()[:10] goods_json = GoodsModelSerializer(goods, many=True) print(goods_json) print(goods_json.data) return Response(goods_json.data)