-
Notifications
You must be signed in to change notification settings - Fork 729
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
Solution #718
base: master
Are you sure you want to change the base?
Solution #718
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.
Thank you for your hard work on this project! While your code meets many of the requirements, there are a few critical issues that need to be addressed before we can approve the pull request:
-
URL Naming Confusion: The naming of URL patterns such as 'movie-detail' and 'movie-list' for
ActorDetail
,ActorList
,GenreDetail
, andGenreList
paths is misleading. This can cause confusion and should be corrected to accurately reflect the resources being accessed. -
Related Name Conflicts: The
related_name
attributes for thegenres
andactors
fields in theMovie
model are not unique or descriptive. This could lead to conflicts and confusion. Consider using more descriptive names like 'movies' to indicate the reverse relationship. -
Unnecessary Class Method: The
get_object
method inGenreDetail
is unnecessarily defined as a class method. Removing the@classmethod
decorator andcls
parameter will simplify the code.
These issues are important to resolve as they impact the clarity and functionality of the code. Once these are addressed, your code will be in great shape! Keep up the good work, and I look forward to seeing the improvements. 😊
✨ 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.
@@ -5,6 +5,32 @@ class Movie(models.Model): | |||
title = models.CharField(max_length=255) | |||
description = models.TextField() | |||
duration = models.IntegerField() | |||
genres = models.ManyToManyField("Genre", blank=True, related_name="genres") |
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 related_name
for the genres
field in the Movie
model should be unique and descriptive. Using 'genres' as the related name can cause confusion and potential conflicts. Consider using something like 'movies' to indicate the reverse relationship from Genre
to Movie
.
@@ -5,6 +5,32 @@ | |||
title = models.CharField(max_length=255) | |||
description = models.TextField() | |||
duration = models.IntegerField() | |||
genres = models.ManyToManyField("Genre", blank=True, related_name="genres") | |||
actors = models.ManyToManyField("Actor", blank=True, related_name="actors") |
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.
Similar to the genres
field, the related_name
for the actors
field should be unique and descriptive. Using 'actors' as the related name can cause confusion and potential conflicts. Consider using something like 'movies' to indicate the reverse relationship from Actor
to Movie
.
@@ -1,6 +1,6 @@ | |||
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 the MovieSerializer
. This will automatically generate fields based on the model and reduce boilerplate code.
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
instead of serializers.Serializer
for the GenreSerializer
. This will automatically generate fields based on the model and reduce boilerplate code.
|
||
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
instead of serializers.Serializer
for the ActorSerializer
. This will automatically generate fields based on the model and reduce boilerplate code.
cinema/urls.py
Outdated
|
||
urlpatterns = [ | ||
path("movies/", movie_list, name="movie-list"), | ||
path("movies/<int:pk>/", movie_detail, name="movie-detail"), | ||
path("genre/", GenreList.as_view(), name="movie-list"), |
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 name 'movie-list' for the GenreList path is misleading. Consider renaming it to 'genre-list' to accurately reflect the resource being accessed.
cinema/urls.py
Outdated
path("movies/", movie_list, name="movie-list"), | ||
path("movies/<int:pk>/", movie_detail, name="movie-detail"), | ||
path("genre/", GenreList.as_view(), name="movie-list"), | ||
path("genre/<int:pk>/", GenreDetail.as_view(), name="movie-detail"), |
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 name 'movie-detail' for the GenreDetail path is misleading. Consider renaming it to 'genre-detail' to accurately reflect the resource being accessed.
cinema/urls.py
Outdated
path("genre/", GenreList.as_view(), name="movie-list"), | ||
path("genre/<int:pk>/", GenreDetail.as_view(), name="movie-detail"), | ||
|
||
path("actor/", ActorList.as_view(), name="movie-list"), |
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 name 'movie-list' for the ActorList path is misleading. Consider renaming it to 'actor-list' to accurately reflect the resource being accessed.
cinema/urls.py
Outdated
path("genre/<int:pk>/", GenreDetail.as_view(), name="movie-detail"), | ||
|
||
path("actor/", ActorList.as_view(), name="movie-list"), | ||
path("actor/<int:pk>/", ActorDetail.as_view(), name="movie-detail"), |
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 name 'movie-detail' for the ActorDetail path is misleading. Consider renaming it to 'actor-detail' to accurately reflect the resource being accessed.
|
||
class GenreDetail(APIView): | ||
@classmethod |
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 get_object
method in GenreDetail
is defined as a class method, but it does not utilize the cls
parameter. Consider removing the @classmethod
decorator and cls
parameter, as they are unnecessary for this method.
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 effort on your submission! 🎉 While the code is approved to help you progress in your learning journey, there are several critical issues that need attention:
-
URL Naming Confusion: The URL patterns for
GenreList
,GenreDetail
,ActorList
, andActorDetail
are misleadingly named as 'movie-list' and 'movie-detail'. It's important to rename these to 'genre-list', 'genre-detail', 'actor-list', and 'actor-detail' to accurately reflect the resources they access. -
Related Name Conflicts: The
related_name
attributes for thegenres
andactors
fields in theMovie
model are not unique or descriptive enough. Consider using names like 'movies_as_genre' and 'movies_as_actor' to better indicate the reverse relationship and avoid potential conflicts. -
Unnecessary Class Method: The
get_object
method inGenreDetail
is unnecessarily defined as a class method. Simplify the code by removing the@classmethod
decorator and thecls
parameter.
Addressing these issues will enhance the functionality and clarity of your code. Keep up the good work, and continue learning from these experiences! 🚀
✨ 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(blank=True, related_name='actors', 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 related_name
for the actors
field in the Movie
model is set to 'actors', which is not unique or descriptive. Consider using a more descriptive name like 'movies_as_actor' to indicate the reverse relationship.
migrations.AddField( | ||
model_name='movie', | ||
name='genres', | ||
field=models.ManyToManyField(blank=True, related_name='genres', 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 related_name
for the genres
field in the Movie
model is set to 'genres', which is not unique or descriptive. Consider using a more descriptive name like 'movies_as_genre' to indicate the reverse relationship.
@@ -5,6 +5,32 @@ class Movie(models.Model): | |||
title = models.CharField(max_length=255) | |||
description = models.TextField() | |||
duration = models.IntegerField() | |||
genres = models.ManyToManyField("Genre", blank=True, related_name="genres") |
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 related_name
for the genres
field in the Movie
model is set to 'genres', which is not unique or descriptive. Consider using a more descriptive name like 'movies_as_genre' to indicate the reverse relationship.
@@ -5,6 +5,32 @@ | |||
title = models.CharField(max_length=255) | |||
description = models.TextField() | |||
duration = models.IntegerField() | |||
genres = models.ManyToManyField("Genre", blank=True, related_name="genres") | |||
actors = models.ManyToManyField("Actor", blank=True, related_name="actors") |
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 related_name
for the actors
field in the Movie
model is set to 'actors', which is not unique or descriptive. Consider using a more descriptive name like 'movies_as_actor' to indicate the reverse relationship.
|
||
urlpatterns = [ | ||
path("movies/", movie_list, name="movie-list"), | ||
path("movies/<int:pk>/", movie_detail, name="movie-detail"), | ||
path("genres/", GenreList.as_view(), name="movie-list"), |
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 URL pattern name 'movie-list' for GenreList
is misleading. Consider renaming it to 'genre-list' to accurately reflect the resource being accessed.
path("movies/", movie_list, name="movie-list"), | ||
path("movies/<int:pk>/", movie_detail, name="movie-detail"), | ||
path("genres/", GenreList.as_view(), name="movie-list"), | ||
path("genres/<int:pk>/", GenreDetail.as_view(), name="movie-detail"), |
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 URL pattern name 'movie-detail' for GenreDetail
is misleading. Consider renaming it to 'genre-detail' to accurately reflect the resource being accessed.
path("genres/", GenreList.as_view(), name="movie-list"), | ||
path("genres/<int:pk>/", GenreDetail.as_view(), name="movie-detail"), | ||
|
||
path("actors/", ActorList.as_view(), name="movie-list"), |
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 URL pattern name 'movie-list' for ActorList
is misleading. Consider renaming it to 'actor-list' to accurately reflect the resource being accessed.
path("genres/<int:pk>/", GenreDetail.as_view(), name="movie-detail"), | ||
|
||
path("actors/", ActorList.as_view(), name="movie-list"), | ||
path("actors/<int:pk>/", ActorDetail.as_view(), name="movie-detail"), |
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 URL pattern name 'movie-detail' for ActorDetail
is misleading. Consider renaming it to 'actor-detail' to accurately reflect the resource being accessed.
@classmethod | ||
def get_object(cls, 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.
The get_object
method in GenreDetail
is unnecessarily defined as a class method. Consider removing the @classmethod
decorator and the cls
parameter to simplify the code.
No description provided.