Skip to content

Commit

Permalink
for AI v4
Browse files Browse the repository at this point in the history
  • Loading branch information
iishchenko committed Oct 17, 2024
1 parent 2c76e22 commit 78660d7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 9 additions & 3 deletions cinema/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ class Meta:


class MovieSerializer(serializers.ModelSerializer):
actors = serializers.PrimaryKeyRelatedField(many=True, queryset=Actor.objects.all(), required=False)
genres = serializers.PrimaryKeyRelatedField(many=True, queryset=Genre.objects.all(), required=False)
actors = serializers.PrimaryKeyRelatedField(
many=True,
queryset=Actor.objects.all(),
required=False)
genres = serializers.PrimaryKeyRelatedField(
many=True,
queryset=Genre.objects.all(),
required=False)

class Meta:
model = Movie
fields = ["title", "description", "duration", "actors", "genres"]
fields = ["title", "description", "duration", "actors", "genres"]
5 changes: 4 additions & 1 deletion cinema/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ class MovieViewSet(viewsets.ModelViewSet):

def update(self, request, *args, **kwargs):
instance = self.get_object()
serializer = self.get_serializer(instance, data=request.data, partial=True)
serializer = self.get_serializer(
instance,
data=request.data,
partial=True)
serializer.is_valid(raise_exception=True)
self.perform_update(serializer)
return Response(serializer.data)

0 comments on commit 78660d7

Please sign in to comment.