From d9d1c092903797dd69489c9766ba43f971a4ebb5 Mon Sep 17 00:00:00 2001 From: Oleh Bohatov Date: Thu, 19 Oct 2023 14:18:19 +0200 Subject: [PATCH] Solution with fixed mistake --- cinema/views.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cinema/views.py b/cinema/views.py index 87c2235f3..12ae4de6c 100644 --- a/cinema/views.py +++ b/cinema/views.py @@ -26,12 +26,9 @@ def get(self, request): def post(self, request): serializer = GenreSerializer(data=request.data) - - if serializer.is_valid(): - serializer.save() - return Response( - serializer.data, status=status.HTTP_201_CREATED - ) + serializer.is_valid(raise_exception=True) + serializer.save() + return Response(serializer.data, status=status.HTTP_201_CREATED) class GenreDetail(APIView):