StaffCoder
Django
DjangoDjango 5.2Python 3.13
18 modules · 72 challengesSign up
Modules18 modules · 72 challenges
Derive forms from models, validate at the field, form and formset layers, and save a parent with its rows in one transaction.
Finish every challenge, or complete the star challenge, to complete the module.

Challenges

4 challenges

Product ModelForm

Sign up to unlock
100%2 of 2 solvedmedium
About this challenge

A product form restates every model field by hand, so it drifts from the model and the model's own rules never reach it. Derive the form from the model with Meta, give the declared fields their widgets and labels, and save through the form with commit=False so the view can stamp the server-set listing code.

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

Unique Slug Validation

Sign up to unlock
100%2 of 2 solvedmedium
About this challenge

A duplicate slug reaches the database instead of coming back as a form error, and editing a page false-positives against its own slug. Layer the slug rules and a self-excluding uniqueness check on the ModelForm, with a unique constraint on the model as the backstop.

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

Bulk Ticket Formset

Sign up to unlock
100%2 of 2 solvedmedium
About this challenge

Registering a group one attendee at a time leaves half the group saved when a row fails. Handle the whole group as one formset submission: a fixed number of rows, a delete box per saved row, validation across every row before anything is written, and an all-or-nothing save.

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

Invoice With Line Items

STAR
Solving it completes the module
100%2 of 2 solvedmedium
About this challenge

An invoice is a header plus a growable table of lines, and a single form cannot take both or keep them consistent. Build the editor from a header ModelForm and an inline item formset bound to the parent, layer field, form and cross-formset rules over it, and save parent and children together inside one transaction.

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.