Overview: Adding Comments to Social Media Posts

Get an overview of the topics covered in this chapter.

We'll cover the following

A social media application is more fun if our users can comment on other posts or even like them. In this section, we’ll first learn how to add comments to posts. We’ll see how we can use database relationships again to create a comment section for each post and ensure the code quality is maintained.

Topics covered in this chapter

In this chapter, we will cover the following topics:

  • Writing the Comment model.

  • Writing the comment serializer.

  • Nesting routes for the comment resource.

  • Writing the CommentViewSet class.

  • Updating a comment.

  • Deleting a comment.

By the end of this chapter, we will be able to create Django models, write Django serializers and validation, and write nested viewsets and routes. We will also have a better understanding of authorization permissions.

Get hands-on with 1200+ tech skills courses.