#1. Create a virtual environment:
bash python -m venv venv
-
Activate the virtual environment:
source venv/bin/activate -
Install Django:
pip install django
-
Save the installed packages to
requirements.txt:pip freeze > requirements.txt -
Start a new Django project:
django-admin startproject <project-name>
- Method: POST
- Endpoint:
api/v1/products - Authentication: Basic or Bearer Token
- Request Body:
{ "name": "product_name", "price": "price" } - Response:
- 1xx: Informational responses
- 2xx: Successful responses
- 201: Product created successfully
- 4xx: Client error responses
- 400: Bad request (invalid input)
- 401: Unauthorized
- 5xx: Server error responses
- 500: Internal server error
- Method: GET
- Endpoint:
api/v1/products - Authentication: Basic or Bearer Token
- Request Body: None
- Response:
{ "id": "_id" }- 1xx: Informational responses
- 2xx: Successful responses
- 200: OK (list of products)
- 4xx: Client error responses
- 401: Unauthorized
- 5xx: Server error responses
- 500: Internal server error
- Method: GET
- Endpoint:
api/v1/products/{id} - Authentication: Basic or Bearer Token
- Request Body: None
- Response:
{ "id": "_id" }- 200: OK (product found)
- 401: Unauthorized
- 404: Not found
- 500: Server error
- Method: PUT or PATCH
- Endpoint:
api/v1/products - Authentication: Basic or Bearer Token
- Request Body:
- PUT: Full object
- PATCH: Partial object
- Response:
{ "id": "_id" }- 200: OK (product updated)
- 401: Unauthorized
- 404: Not found
- 500: Server error
- Method: DELETE
- Endpoint:
api/v1/products/{id} - Authentication: Basic or Bearer Token
- Request Body: None
- Response:
{ "delete": "success" }- 200: OK (product deleted)
- 401: Unauthorized
- 404: Not found
- 500: Server error