I am trying to check if the status
of a buyer is equal to buyer_completed
, then i perform some operations, i also want to return a response if the conditions does not match, but the error seems not to be showing as expected.
class SellerCompleteOrder(generics.RetrieveUpdateAPIView):
serializer_class = OrderSerializer
# permission_classes = [IsAuthenticated]
def get_object(self):
user_id = self.kwargs['user_id']
order_id = self.kwargs['order_id']
user = User.objects.get(id=user_id)
order = Orders.objects.get(seller=user, id=order_id)
if order.buyer_status == "buyer_completed":
order.seller_status = "seller_completed"
order.save()
return Response({"Seller Have Marked Order as Completed":order})
else:
return Response({"Seller cannot mark order as completed":order})
this is the response