Skip to content

The path of a request ​

What happens when the web front end sends POST /api/products/ to create a product?

Step by step ​

  1. Traefik receives the HTTPS request and passes it to the API container (port 8000).
  2. Gunicorn hands the request to one of its 3 Django workers.
  3. Django checks that the domain name is in ALLOWED_HOSTS. Otherwise: 400.
  4. urls.py: /api/ is delegated to the DRF router, which recognises products/ and the POST method → the ViewSet's create action.
  5. The serializer checks the data against the model's rules.
  6. If all is well, the ORM inserts the row and the API answers 201 with the created product, id and dates included.

The other methods ​

RequestViewSet actionResponse
GET /api/products/list200 + array, sorted by id
GET /api/products/3/retrieve200 or 404
PUT /api/products/3/update200, all fields required
PATCH /api/products/3/partial_update200, only the fields sent
DELETE /api/products/3/destroy204, no content
GET /healthhealth_check200 + {"status": "ok"}, without touching the database

The code for each step is explained in The products API.