Writing the Comment Model and Serializer
Follow step-by-step instructions to create the Comment model and serializer.
A comment in the context of this project will represent short text that can be viewed by anyone but only be created or updated by authenticated users.
Feature requirements
Here’s what the requirements for this feature look like:
Any user can read comments.
Authenticated users can create comments under posts.
The comment author and post author can delete comments.
The comment author can update posts.
The Comment
table
Looking at these requirements, we can definitely start with writing the model first. But first, let’s quickly talk about the structure of the Comment table in the database:
Get hands-on with 1200+ tech skills courses.