view.py
class ConfirmCourierAPIView(views.APIView):
serializer_class = ConfirmCourierSerializer
def post(self, request, delivery_id, *args, **kwargs):
delivery = get_object_or_404(Delivery, id=delivery_id)
conf_delivery = get_object_or_404(CourierPropouse, delivery=delivery)
if conf_delivery.final_price:
final_price = conf_delivery.final_price
else:
final_price = delivery.price
serializer = self.get_serializer_class()(data=request.data)
if serializer.is_valid() and \
delivery.customer == request.user and \
delivery.status == 'open':
serializer.save(delivery=delivery, final_price=final_price)
delivery.status = 'closed'
delivery.save()
return Response(status=status.HTTP_201_CREATED)
return Response(status=status.HTTP_400_BAD_REQUEST)
При POST запросе ошибка 405