The path of a request
What happens when the web front end sends POST /api/products/ to create a product?
Step by step
- Traefik receives the HTTPS request and passes it to the API container (port 8000).
- Gunicorn hands the request to one of its 3 Django workers.
- Django checks that the domain name is in
ALLOWED_HOSTS. Otherwise: 400. urls.py:/api/is delegated to the DRF router, which recognisesproducts/and thePOSTmethod → the ViewSet'screateaction.- The serializer checks the data against the model's rules.
- If all is well, the ORM inserts the row and the API answers
201with the created product,idand dates included.
The other methods
| Request | ViewSet action | Response |
|---|---|---|
GET /api/products/ | list | 200 + array, sorted by id |
GET /api/products/3/ | retrieve | 200 or 404 |
PUT /api/products/3/ | update | 200, all fields required |
PATCH /api/products/3/ | partial_update | 200, only the fields sent |
DELETE /api/products/3/ | destroy | 204, no content |
GET /health | health_check | 200 + {"status": "ok"}, without touching the database |
The code for each step is explained in The products API.