from rest_framework.views import APIView from rest_framework.viewsets import GenericViewSet from rest_framework.response import Response from .serializers import PlatSimInfoSerializer from .models import PlatSimInfo # Create your views here. class GetBaseType(APIView): def get(self, request): queryset = PlatSimInfo.objects.raw("SELECT id,device_type FROM plat_sim_info GROUP BY device_type;") data = [] for i in queryset: data.append(i.device_type) return Response(data) class PlatformIOTCardViewSet(GenericViewSet): queryset = PlatSimInfo.objects.all() serializer_class = PlatSimInfoSerializer