from django.shortcuts import render from rest_framework import viewsets from rest_framework.parsers import JSONParser from django.http import HttpResponse, JsonResponse from otpauth.serializer import VerifySerializer, OTPSerializer from otpauth.models import OTPSeed class OTPVerifyViewSet(viewsets.ModelViewSet): serializer_class = OTPSerializer queryset = OTPSeed.objects.all() class VerifyViewSet(viewsets.ViewSet): serializer_class = VerifySerializer def create(self, request): data = JSONParser().parse(request) serializer = VerifySerializer(data=data) if serializer.is_valid(): print("is valid") print(serializer) #serializer.save() return JsonResponse(serializer.data, status=201) return JsonResponse(serializer.errors, status=400) def get_queryset(self): return []