Nesting Routes for the Comment Resource
Implement nested routing for posting and retrieving comments under posts.
Now that the comment serializer is ready, we can proceed to write the viewsets concerning the comment feature. But before that, let’s talk about the endpoint of the resource.
To create, update, or delete comments, we need to add ViewSet
. In the comment directory, create a file called viewsets.py
. This file will contain the code for the
CommentViewSet
class. We won’t be writing all the code for this viewset because we need to get some clear ideas on the structure of the endpoint.
So, add the following content for the moment:
Get hands-on with 1200+ tech skills courses.