Writing Post Viewsets
Learn to create viewset for the Post model, and create a sample post to test the endpoint.
We'll cover the following
For the following endpoint, we’ll only be allowing the POST
and GET
methods. This will help us have the basic features working first.
Requirements
The code should follow these rules:
Only authenticated users can create posts.
Only authenticated users can read posts.
Only
GET
andPOST
methods are allowed.
Inside the post
directory, create a file called viewsets.py
. Into the file, add the following content:
Get hands-on with 1400+ tech skills courses.