views.py 657 B

123456789101112131415161718192021
  1. from rest_framework.views import APIView
  2. from rest_framework.viewsets import GenericViewSet
  3. from rest_framework.response import Response
  4. from .serializers import PlatSimInfoSerializer
  5. from .models import PlatSimInfo
  6. # Create your views here.
  7. class GetBaseType(APIView):
  8. def get(self, request):
  9. queryset = PlatSimInfo.objects.raw("SELECT id,device_type FROM plat_sim_info GROUP BY device_type;")
  10. data = []
  11. for i in queryset:
  12. data.append(i.device_type)
  13. return Response(data)
  14. class PlatformIOTCardViewSet(GenericViewSet):
  15. queryset = PlatSimInfo.objects.all()
  16. serializer_class = PlatSimInfoSerializer