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)