-
Notifications
You must be signed in to change notification settings - Fork 722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Develop #772
base: master
Are you sure you want to change the base?
Develop #772
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on your submission! 🎉 The code is mostly compliant with the task requirements, and there are no critical issues affecting functionality. While there are some minor improvements suggested, such as using serializers.ModelSerializer
to simplify your serializers and refining the __str__
methods for better readability, these do not impact the core functionality of your application. Keep up the good work, and consider these suggestions for future enhancements! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
cinema/models.py
Outdated
def __str__(self): | ||
return f"{self.first_name}{self.last_name}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The __str__
method for the Actor
model should include a space between the first and last names for better readability. Consider changing it to return f"{self.first_name} {self.last_name}"
.
cinema/models.py
Outdated
def __str__(self): | ||
return self.title | ||
return f"{self.title}:({self.genres}, {self.duration})" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the __str__
method of the Movie
model, directly including self.genres
will not display the genre names as expected. You might want to use a method to join the genre names into a string, such as ', '.join(genre.name for genre in self.genres.all())
.
Genre, | ||
Actor, | ||
CinemaHall | ||
) | ||
|
||
|
||
class MovieSerializer(serializers.Serializer): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using serializers.ModelSerializer
for the MovieSerializer
class. This would automatically generate the create
and update
methods based on the model fields, reducing boilerplate code.
@@ -22,3 +27,48 @@ | |||
instance.save() | |||
|
|||
return instance | |||
|
|||
|
|||
class ActorSerializer(serializers.Serializer): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using serializers.ModelSerializer
for the ActorSerializer
class to simplify the code by automatically handling the create
and update
methods.
return instance | ||
|
||
|
||
class GenreSerializer(serializers.Serializer): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using serializers.ModelSerializer
for the GenreSerializer
class to reduce the need for manually defining the create
and update
methods.
return instance | ||
|
||
|
||
class CinemaHallSerializer(serializers.Serializer): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using serializers.ModelSerializer
for the CinemaHallSerializer
class to automatically handle the create
and update
methods, simplifying the code.
cinema/views.py
Outdated
|
||
class GenreList(APIView): | ||
@staticmethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of @staticmethod
for the get
and post
methods in GenreList
is unnecessary. These methods should be instance methods, not static methods, as they rely on the request
object.
cinema/views.py
Outdated
|
||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) | ||
class GenreDetail(APIView): | ||
@staticmethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, the @staticmethod
decorator is not needed for the get_object
method in GenreDetail
. It should be an instance method to maintain consistency with Django's class-based views.
No description provided.