Djangocon EU: Django forms in the age of HTMX: the single field form - Hanne Moa¶
(One of my summaries of the 2026 Djangocon EU in Athens).
You can go totally overboard with forms. Forms nested in forms. A list of forms. A recursive list of forms. She had to work with lots of elaborate forms/questionaires that needed to have many variants. Especially questionaires can drive you crazy with their dynamic form behaviour.
A solution is to have a single field at the time. So: many forms with one single field. A little piece of htmx can load the single field forms when you click their “edit” button. Some example code is at https://github.com/Uninett/singlefieldform . (The presentation is there, too, in the slides/ directory).
As an example, she showed a user preferences form. For every new preference, you only need to add an extra “single field form” which works on its own. Handy.
The magic is that every field inherits from a SingleFieldMixin, which registers itself with the “main form page” registry. The main form page can iterate over the single field forms.
Tip: using subclasses is the easiest way to get a plugin mechanism to work. (But de-activating the mechanisim is hard.)
Unrelated photo explanation: a recent trip to the “Modellbundesbahn” in Germany. The same Ottbergen signal box as in this picture, but now on the great “Modellbundesbahn” model railway layout.