StaffCoder
Django
DjangoDjango 5.2Python 3.13
18 modules · 72 challengesSign up
Modules18 modules · 72 challenges
Build the endpoint itself: APIViews returning their own responses, generic views wired to a queryset, a ViewSet under a router, and an API where resource routes and a hand-written endpoint live together.
Finish every challenge, or complete the star challenge, to complete the module.

Challenges

4 challenges

API View Responses

Sign up to unlock
—No data yetmedium
About this challenge

The product endpoints are plain Django views that return JsonResponse with 200 for every outcome, accept whatever method arrives, and read the body with a hand-rolled json.loads that only understands JSON. Reimplement both endpoints as APIView classes that read request.data, return a Response with the status code each outcome deserves, and offer only the methods they define.

Read the full problem
Solved in a browser IDE and graded by tests. Sign up to solve

Generic API Views

Sign up to unlock
—No data yetmedium
About this challenge

Every method of the article API spells out the same fetch-validate-save-respond cycle by hand, and the hand-written code takes the author from whatever the client posted. Replace both classes with DRF's generic list-create and retrieve-update-destroy views, declaring queryset and serializer_class, and set the author from the request user in perform_create.

Read the full problem
Solved in a browser IDE and graded by tests. Sign up to solve

ViewSet With Router

Sign up to unlock
—No data yetmedium
About this challenge

The recipe API spread one resource across five hand-written URL patterns and five separate views that kept drifting apart, and publishing was bolted on as an unrelated endpoint. Consolidate the resource into a ModelViewSet registered on a DefaultRouter under an explicit basename, with a detail-level publish action and a list-level recent action, each restricted to the method it declares.

Read the full problem
Solved in a browser IDE and graded by tests. Sign up to solve

Task Board API

STAR
Solving it completes the module
—No data yetmedium
About this challenge

A team task board needs its whole API surface - task CRUD, workflow operations and a board summary - and today it is a tangle of JsonResponse views that answer 200 for everything. Build the API: a task ModelViewSet on a router with named routes, partial updates, a server-set creator, a detail-level complete action, a list-level overdue action and a board-summary APIView, with the defined status code for every outcome.

Read the full problem
Solved in a browser IDE and graded by tests. Sign up to solve

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.