views.py 495 B

123456789101112131415
  1. from rest_framework.views import APIView
  2. from rest_framework.generics import GenericAPIView
  3. from rest_framework.response import Response
  4. from .models import PlatIOTCardInfo
  5. # Create your views here.
  6. class GetBaseType(APIView):
  7. def get(self, request):
  8. queryset = PlatIOTCardInfo.objects.raw("SELECT id,device_type FROM IOTCard_platiotcardinfo GROUP BY device_type;")
  9. data = []
  10. for i in queryset:
  11. data.append(i.device_type)
  12. return Response(data)