Skip to content

Commit

Permalink
add raise_exception=True to is_valid()
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Katkalov committed Oct 18, 2023
1 parent 83ec2e3 commit 889013f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cinema/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit 889013f

Please sign in to comment.