def put(self, request, file_id): print 'inside PUT method' serializer = FileSerializer(data=request.DATA) if not serializer.is_valid(): return Response(serializer.errors, status= status.HTTP_400_BAD_REQUEST) else: data = serializer.data t = InputFile(id=inputfile_id, input_user=request.user, audio_file=request.FILES,\ rec_date=datetime.now()) t.save() return Response(status=status.HTTP_200_OK)
def put(self, request, file_id): print 'inside PUT method' serializer = FileSerializer(data=request.DATA) if not serializer.is_valid(): return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) else: data = serializer.data t = InputFile(id=inputfile_id, input_user=request.user, audio_file=request.FILES,\ rec_date=datetime.now()) t.save() return Response(status=status.HTTP_200_OK)
def post(self, request, filename, format=None): print 'post method in FileView' serializer = FileSerializer(data=request.DATA) print request.FILES if not serializer.is_valid(): return Response(serializer.errors, status= status.HTTP_400_BAD_REQUEST) else: data = serializer.data input_user = request.user t = File(input_user=input_user, audio_file=request.FILES) t.save() request.DATA['id'] = t.pk # return id return Response(request.DATA, status=status.HTTP_201_CREATED)
def post(self, request, filename, format=None): print 'post method in FileView' serializer = FileSerializer(data=request.DATA) print request.FILES if not serializer.is_valid(): return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) else: data = serializer.data input_user = request.user t = File(input_user=input_user, audio_file=request.FILES) t.save() request.DATA['id'] = t.pk # return id return Response(request.DATA, status=status.HTTP_201_CREATED)
def get(self, request): print 'get method in FileView' print request.FILES queryset = InputFile.objects.all() files = InputFile.objects.filter(input_user=request.user.id) serializer = FileSerializer(files, many=True, context={'request': request}) return Response(serializer.data)