Esempio n. 1
0
def feedbacks_list(request):
    if request.method == 'GET':
        feedbacks = Feedback.objects.all()
        serializer = FeedbackSerializer(feedbacks, many=True)
        return Response(serializer.data)
    elif request.method == 'POST':
        serializer = FeedbackSerializer(data=request.data)
        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data, status=status.HTTP_201_CREATED)
        return Response({'error': serializer.errors},
                        status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Esempio n. 2
0
def feedback(request):
    ser = FeedbackSerializer(data=request.data)
    if ser.is_valid():
        ser.save()
        return Response(status=status.HTTP_204_NO_CONTENT)
    return Response(data=ser.errors, status=status.HTTP_400_BAD_REQUEST)
Esempio n. 3
0
def feedback(request):
    ser = FeedbackSerializer(data=request.data)
    if ser.is_valid():
        ser.save()
        return Response(status=status.HTTP_204_NO_CONTENT)
    return Response(data=ser.errors, status=status.HTTP_400_BAD_REQUEST)