You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
700 B

2 years ago
from rest_framework.views import APIView
from rest_framework.response import Response
from apps.goods.models import *
2 years ago
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)