-
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
Complete project with serializers and views(API, Generic and ViewSet) #771
base: master
Are you sure you want to change the base?
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.
Your work is almost there! 🎉 However, there are a couple of critical issues that need addressing before we can approve the PR. The putch
typo in the GenreDetail
class is crucial as it affects the functionality of handling PATCH requests. Additionally, defining related_name
for the ManyToManyField
in the Movie
model is required to meet the task requirements. Once these are fixed, your implementation will be in great shape! Keep up the good work! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review
button in the Reviewers tab.
cinema/serializers.py
Outdated
@@ -1,6 +1,5 @@ | |||
from rest_framework import serializers | |||
|
|||
from cinema.models import Movie | |||
from cinema.models import Movie, Actor, Genre, 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
instead of serializers.Serializer
for MovieSerializer
. This will simplify the code by automatically generating fields and methods based on the Movie
model.
cinema/serializers.py
Outdated
@@ -22,3 +21,60 @@ | |||
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 ActorSerializer
to automatically handle fields and methods based on the Actor
model.
cinema/serializers.py
Outdated
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 GenreSerializer
to simplify the code by leveraging the Genre
model.
cinema/serializers.py
Outdated
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 CinemaHallSerializer
to automatically handle fields and methods based on the CinemaHall
model.
cinema/views.py
Outdated
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) | ||
|
||
if request.method == "DELETE": | ||
movie.delete() | ||
def putch(self, request, pk): |
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.
There is a typo in the method name putch
. It should be patch
to correctly handle HTTP PATCH requests for partial updates.
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.
Review Summary
Great progress on the implementation! 🎉 The code is mostly aligned with the task requirements, and you've addressed several previous issues effectively. Here are some key points to consider for improvement:
-
related_name
forManyToManyField
: TheMovie
model is missing therelated_name
attribute for itsManyToManyField
fields (actors
andgenres
). Adding this attribute is crucial for enabling reverse querying from theActor
andGenre
models, as specified in the task checklist. -
Typo Correction: The typo in the
GenreDetail
class has been corrected, which is a positive step forward. The method is now correctly namedpatch
, aligning with standard HTTP methods. -
General Code Quality: The serializers, URL routing, and view implementations are well-structured and meet the task requirements. Keep up the good work in maintaining clean and efficient code.
While the decision is to APPROVE this pull request to help you move forward with your learning, please ensure to address the missing related_name
attributes in future updates. This will enhance the functionality and maintainability of your code. Keep learning and improving! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
migrations.AddField( | ||
model_name='movie', | ||
name='actors', | ||
field=models.ManyToManyField(to='cinema.actor'), |
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 ManyToManyField
for actors
in the Movie
model should include a related_name
attribute as per the task requirements. This allows for reverse querying from the Actor
model.
migrations.AddField( | ||
model_name='movie', | ||
name='genres', | ||
field=models.ManyToManyField(to='cinema.genre'), |
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 ManyToManyField
for genres
in the Movie
model should include a related_name
attribute as per the task requirements. This allows for reverse querying from the Genre
model.
class Movie(models.Model): | ||
title = models.CharField(max_length=255) | ||
description = models.TextField() | ||
duration = models.IntegerField() | ||
actors = models.ManyToManyField(Actor) |
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 ManyToManyField
for actors
in the Movie
model should include a related_name
attribute as per the task requirements. This allows for reverse querying from the Actor
model.
class Movie(models.Model): | ||
title = models.CharField(max_length=255) | ||
description = models.TextField() | ||
duration = models.IntegerField() | ||
actors = models.ManyToManyField(Actor) | ||
genres = models.ManyToManyField(Genre) |
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 ManyToManyField
for genres
in the Movie
model should include a related_name
attribute as per the task requirements. This allows for reverse querying from the Genre
model.
No description provided.