def put(self, request, pk, format=None):
     record = self.get_object(pk)
     serializer = RecordsSerializer(record, data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
 def post(self, request, format=None):
     if type(request.data) == list:
         serializer = RecordsSerializer(data=request.data, many=True)
     else:
         serializer = RecordsSerializer(data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
    def post(self, request, username, format=None):
        if type(request.data) == list:
            userid = CustomUser.objects.get(username=username).id
            data = request.data
            for d in data:
                d["user"] = userid
            serializer = RecordsSerializer(data=data, many=True)
        else:
            userid = CustomUser.objects.get(username=username).id
            data = request.data
            data["user"] = userid
            serializer = RecordsSerializer(data=data)

        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data, status=status.HTTP_201_CREATED)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
 def get(self, request, username, format=None):
     record = self.get_object(username)
     serializer = RecordsSerializer(record, many=True)
     return Response(serializer.data)
 def get(self, request, pk, format=None):
     record = self.get_object(pk)
     serializer = RecordsSerializer(record)
     return Response(serializer.data)
 def get(self, request, format=None):
     record = PatientRecord.objects.all()
     serializer = RecordsSerializer(record, many=True)
     return Response(serializer.data)