Note: We will be continuing with the project we started in the previous week. If you haven't completed the tasks from the previous week, please complete them first.
You have to install Django REST Framework in your project. You can refer to the official documentation for more details.
- Install Django REST Framework using pip in the virtual environment.
- Update
settings.py
file to add Django REST Framework to the installed apps.
Now we will be transforming our existing Django project into a REST API. You can refer to the official documentation for more details.
- Modify
views.py
to add the necessary logic for the APIs. You are only allowed to use function based views for this task. - Create 5 APIs for each of the following:
- Get all products
- Get a single product (by id)
- Add a product
- Delete a product
- Purchase a product
- Test the APIs using Postman and make sure they are working as expected.
Note: You can create new models and/or modify the existing models if you want to.
You have to add authentication to your project. You can refer to the official documentation for more details.
- Install Simple JWT using pip in the virtual environment.
- Update
settings.py
,urls.py
and other neccessary files to add Simple JWT to the project. - Create 2 APIs for each of the following:
- Login
- Signup
- Test the APIs using Postman and make sure they are working as expected.
- Make
Add Product
andPurchase Product
APIs created in the previous task accessible only to authenticated users andDelete Product
API accessible only to the user who created the product. Put necessary restrictions onPurchase Product
API so that a user can only purchase a product once, a user cannot purchase a product created by them, etc. (DO NOT delete the product after it has been purchased.)
Now we will be finally documenting our APIs in Postman. You can refer to the official documentation for more details.
- Create a new collection in Postman and add all the APIs created in the previous tasks to it.
- Add documentation for each API in the collection.
- Test all the APIs and make sure they are working as expected.
- Explain the working of each API in the documentation in 30-50 words.
- Export the collection as a JSON file and add it to the
backend
directory.
- Learn about class based views in Django and convert all the function based views created in Task 3B to class based views.
- Learn about Django CORS Headers and add it to your project.
- Learn about OpenAPI, and use Swagger to make an OpenAPI compatible documentation for your project