def ZXG_list(request, format=None): """ List all snippets, or create a new snippet. """ if request.method == 'GET': values = BlockDetail.objects.all() serializer = BKDetailSerializer(values, many=True) return Response(serializer.data) elif request.method == 'POST': serializer = BKDetailSerializer(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 ZXG_detail(request, pk, format=None): """ Retrieve, update or delete a snippet instance. """ try: values = BlockDetail.objects.get(pk=pk) except BlockDetail.DoesNotExist: return Response(status=status.HTTP_404_NOT_FOUND) if request.method == 'GET': serializer = BKDetailSerializer(values) return Response(serializer.data) elif request.method == 'PUT': serializer = BKDetailSerializer(values, data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) elif request.method == 'DELETE': values.delete() return Response(status=status.HTTP_204_NO_CONTENT)