-
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
API Views #374
base: master
Are you sure you want to change the base?
API Views #374
Conversation
cinema/views.py
Outdated
return Response(serializer.data, status=status.HTTP_200_OK) | ||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) |
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.
simplify your code with raise_exception=True https://stackoverflow.com/questions/40348981/django-rest-framework-raise-exception-true
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.
LGTM, one comment is left for consideration.
movie = get_object_or_404(Movie, pk=pk) | ||
class GenreDetail(APIView): | ||
def get_object(self, pk: int) -> Genre: | ||
return get_object_or_404(Genre, id=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.
You could use get_object_or_404
directly in your methods where needed, there is no need to allocate a separate method for that.
No description provided.