From 889013f235efa7e28b5b76ec2f58f3e263f54d4d Mon Sep 17 00:00:00 2001 From: Max Katkalov Date: Wed, 18 Oct 2023 08:18:51 +0300 Subject: [PATCH] add raise_exception=True to is_valid() --- cinema/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cinema/views.py b/cinema/views.py index 36e643c3b..d69cf7dbc 100644 --- a/cinema/views.py +++ b/cinema/views.py @@ -31,7 +31,7 @@ def get(self, request: Request) -> Response: def post(self, request: Request) -> Response: serialized_data = GenreSerializer(data=request.data) - if serialized_data.is_valid(): + if serialized_data.is_valid(raise_exception=True): serialized_data.save() return Response( serialized_data.data, status=status.HTTP_201_CREATED @@ -53,14 +53,14 @@ def get(self, request: Request, pk: int) -> Response: def put(self, request: Request, pk: int) -> Response: genre_object = self.get_object(pk=pk) serializer = GenreSerializer(genre_object, data=request.data) - if serializer.is_valid(): + if serializer.is_valid(raise_exception=True): serializer.save() return Response(serializer.data, status=status.HTTP_200_OK) def patch(self, request: Request, pk: int) -> Response: genre_object = self.get_object(pk=pk) serializer = GenreSerializer(genre_object, data=request.data) - if serializer.is_valid(): + if serializer.is_valid(raise_exception=True): serializer.save() return Response(serializer.data, status=status.HTTP_200_OK)