Django forms in the age of HTMx: the single field form

This video features Hanne Moa at DjangoCon Europe 2026 in Athens, Greece.

Django forms in the age of HTMx: the single field form
0:23:28
Published July 20, 2026
10 views

TALK: Django forms in the age of HTMx: the single field form by Hanne Moa

There are many ways to do "interesting" things with forms... With HTMx it is possible to treat any HTML tag as a form, without using form tags. It becomes easy to alter just one field of a form: click on the field to swap out the presentation with a suitable input field, then submit that single field on pressing Enter. What is not necessarily so easy is adapting the use of Django's forms so that they are used both for validation and rendering of that single field, and smuggling in the necessary context a form widget needs if one skips the form-tag and uses widget templates to render the inputs. Incidentally it does become easy to have plugin-able forms... This talk will briefly look at previous "interesting" (ab)uses of Django forms, followed by demonstrating some hands-on techniques and patterns for working with single fields, using a special made demonstration site and a production service that was converted in 2024-2025 from a SPA using REACT to an MPA using HTMx: Argus.

Django: https://docs.djangoproject.com/
HTMx: https://htmx.org Live
Argus demo: https://argus-demo.uninett.no/
Argus code: https://github.com/Uninett/
Argus Code for singlefield demo: https://github.com/Uninett/singlefieldform
Slides: https://github.com/Uninett/singlefieldform/tree/main/slides

More information: https://2026.djangocon.eu/speakers/ZJAQE7/

Follow DjangoCon Europe on social media:
*X - https://x.com/DjangoConEurope/
*LinkedIn - https://www.linkedin.com/company/djangocon-europe/
*Mastodon - https://fosstodon.org/@djangoconeurope

#django #djangocon #djangoconeurope #djangoconeurope2026

Transcript

2,700 words · auto-generated · en Show

Automatically transcribed, so expect mistakes in names and technical terms.

0:03

Speaker 1: Thank you. No, let me introduce to you uh Hanne Moa. Let's welcome her. With a s nice applause. She she is a devo developer, mostly you say. Um what I found really impressive using Python since version 1. 5 Yeah, that's uh yeah. I I I need to talk to you what has changed since I I have no experience in that. So and I think otherwise you are part of the N Norwegian National Research and Education Network. And we'd love to hear about the single field form.

0:37

Speaker 2: Yes. Thank you. So this is the least interesting slide. I'm supposed to say something about um Enrons. We basically run the academic internet. So if you have an account at university , your internet will be above on routers and cables and systems that we build. I'm not allowed to read my work address uh on my phone. So but that's the address I have to use. So um but I have another address if you're interested if you want to contact later

1:23

Speaker 2: and I have private presence on social media so if you're interested come ask me later So, this is what we will be going through, and I hope we get to the bonuses. I'll be very quick on the first one: Horrors of the Past. I've been using uh Django since 2008. Anybody remember the form we said? And anybody remember when it was removed? It never worked for me. So the first one If anybody remembers the form, this is much worse. Much worse. So uh there are two demos. One of them is online and you can follow along and the other one is just source code so you can just click in on the GitHub repo and look at it if you want

2:13

Speaker 2: some talking. So we have a form. This was 2014. This was a very bureaucratic process. There was a form that needed to be filled in every two years So it was valid for two years and it changed twice a year and had to stay valid for so four periods. And they would add fields, remove fields, and rem uh change uh subsets of fields. So um we figured out some stable subsets of fields. So we put forms inside a list. And since I was much younger, I put the list inside a form.

3:01

Speaker 2: And since um well the users wanted paging and you could use the form wizard because they were very uh It was very important for them to be able to sort of yep, I'm on page six. Can you please go look at page six? So we gave I'm just making it take less place. Um so we put the form scene on our page We have a page number, multiple pages, and I think you can guess what comes next. Yes, so uh I do not recommend recursive forms. Really. I mean I've been there. Uh get me drunk, I can tell you about it I will not go into details.

3:48

Speaker 2: Don't do it. So a little bit later was the birth of the single field form. So it was another questionnaire that needed to be filled out, but um when this time when you when you um answered certain questions uh you would be sent to different questions. So it's a uh true and adventure style. And um since I am a computer science graduate, of course, everything is graph theory. So I made a finite statement user in the database So each question is a single-form field, though sometimes with multi-vidgest. I don't recommend multi-vidgets either, that can

4:33

Speaker 2: get complex really quickly. So the um answers there Where it's a foreign key to the field that was a row in the database. And all of this will be stored in back then a text field because we didn't have JSON fields yet But this was the start of the single field and there's so much cool stuff you can do when you think one field at a time instead of a full um Oof full form. Um this one is being deprecated because the people um who were paying for it suddenly decided it was much better to do just do everything on paper. So they're back to paper now

5:19

Speaker 2: I think. I mean you fill in this enormous question with 280 questions with like branches like this And nobody reuse it and is put in a file. But it it just has to exist. It's one of those nice things about bureaucracy that drives developers and everybody else crazy. So a single field form is a pattern. Obviously you only have one field I will need an example and this is a very simple slightly simplified from the tutorial, I think junk tutorial, with this extra JSON field And the magic first part of the magic is just this.

6:08

Speaker 2: This one makes it much easier to use it inside templates. That's all. I mean you don't have to you could you could do it other ways, but this one I think is very readable And we have Yeah, because we will have multiple forms. We call multiple fields, multiple forms. And has a template. I was thinking of using Django Partial template, but this is so simple I didn't actually need to. This little uh demo thing. And this is all the ADMX things you will be seeking today. Because it's this is all that's needed. When you have already done all the heavy lifting in Python

6:57

Speaker 2: And here's um as you can see this one does not inherit from anything, it's just a uh fragment. That's also why I use the underline here. So if I had used stronger partials then this would be the partial probably. And if anybody now has a laptop, uh you can find the code for what we'll be looking at here. And the second demo is online, so you can follow that on along as well. There is uh open users, so I'll switch to this one. So this is your standard old style form.

7:43

Speaker 2: So add one. Uh A B uh since I haven't put in any validation we'll just make a big number. Yep, we have a nice little book on the author and the year. The top one is the title Outer and yeah, which is oops error. Okay, um and digital thing is what's in the JSON So you can look at the same thing.

8:28

Speaker 2: Oh. So um you haven't seen the missing form here. This is uh a form that defines Trivia. This is not HMX, this is just plain Django. Maybe you don't have to be that far into the future. And titles really should have like a start with a big letter and so on, right? And then we add HDMX. First thing I thought about whether

9:14

Speaker 2: Swagger mixed with this because I love love love Patrick's that does this. No dialogue. Just edit what you need to edit and move on with your life. So I can just define a new one of these with whatever data type I want and then it'll just magically pop up. inside this tourist JSON box. So if we look at I will look at this one. Oof, I have it logged in. And for that I need my uh shit. I'll go

10:00

Speaker 2: drop that one. See if I have the correct password and yes. So uh per page that's a single file form. Uh everything here works with get I'm not used to this or This changes the uh GUT requests of pair and it's uh made that way to be bookmarkable so you can share bookmarks. Uh updating every is not a single page uh single uh file form because it's uh it sends a post

10:45

Speaker 2: Uh time frame sense uh is the same. Um Everything every field here is a single file form. So every time we need a new preference, we just Make a new single field four with some magic um to store it for us. So um And as you can see, I mean we're working with networking. This is a dashboard that collects information from um all our all our shit actually. And I could actually say it it can connect any anything from anything. I've I've been using it for uh as a Pomodoro

11:30

Speaker 2: timer. It's just a matter of what dot data you send in. And it can send notifications for you and we have recently switched to the Django tasks. System. We used to use a background process with the pos with the multiprocess library if I remember correctly. And this program also started out as uh Django Rest framework plus React. But we only had the one front-end developer. So we had got some funding, so we wrote it in HTMX. This is um Tailwind, DC UI, HTMX, and Dango52 right now You can use uh Django toss on 5v2, you just have to uh

12:17

Speaker 2: use another library. So back to the uh slides. What did I test? Oh, yeah, Mr. Wii, Mr. Y. No. So um this is the code for the little demo I saw in the beginning.

13:04

Speaker 2: And this these are my slides, so let's do the raw here. Oh, that's annoying. That was unexpected. Okay, I'll download it. And there we are. Wrong color. Let's see. Oh yeah, it's the previous version. So

13:53

Speaker 2: So here's the magic saw in the beginning Whenever you subplass single field form mixing, it magically turns up in the list of forms. This is actually also the first time I've done this with model forms because usually we're only using this with uh when we store the data in JSON. So um Poof. So I'm glad I got it to work. And You're on the buses already. And when you're doing HTMX with Django um template with Django

14:39

Speaker 2: widget templates, you will not necessarily have all the context you need. So what you do is you use your own uh widget mix in to send in all the context that you need, like request or age things. You have the others that you can send in, but um it's one thing. I mean namespaces are a good thing, right? So you can add in more namespaces like this So we usually have one for HX and one for request and usually also send in um if you want to um put the uh actual get Ajax get on the um directly on the um thingy itself and uh and it is a very difficult URL you can pre-compute it in um the view and then when you make the form

15:26

Speaker 2: you can send in the URL you need. So second bonus um if you go back here back back back back back This is uh using subcluses and run the subclusor. This is a really nice way to make plugins. It's the easiest, very easiest, absolutely easiest ways to make plugins in the universe. There's just one problem. You cannot get rid of them. They're always there. So if you want to be able to get rid of a plugin, you have to be able to unregister it or replace it with something else without uh fooling around with the uh um MRO and stuff

16:15

Speaker 2: So uh by using init surplus Instead of just going to the subclass and putting the registry on the topmost um Or you could just actually have a registry plugin. You can register and unregister any plugin, and as a field with this is uh imported , this will just happen. Um let's see, that's let's go here. That's the stuff about Argus and uh our logo and more of the um

17:01

Speaker 2: More links for you. You've already seen the uh all of this is on GitHub, so you can just click in and you have the sandbox there that you can use to play around with cool HTMX stuff And um oopsie That's the last slide.

17:29

Speaker 1: So uh despite the

17:33

Speaker 2: Why did it start? Why did it work in the beginning?

17:35

Speaker 1: I don't know. I don't know. But despite that, uh great talk. Thank you so much. We still have time for some questions, please. Questions Hi

17:50

Speaker 3: Hannah, thank you. That was super that's really interesting that the um You have so many forms going on because it it's like one field per um one one form per field. It's a I'd be very tempted that, but I'd be scared of explosion. But it's easy to handle because of your system there.

18:09

Speaker 2: Yeah, well you have you have uh different subclasses for different needs So uh if I can find the Argus code. Uh GitHub. So we have for at the moment two different types of single field forms. It's the ones that are in the dashboard at the bottom. That creates this get stuff. And some of them also saves a preference, uh user preference. Um and Well, because of the slide, this uh since um the HTMX

18:54

Speaker 2: uh rewrite was partly funded by GEONT. And the Django Tosk stuff was part funded by NoodleNet, that's why we have that one there. What they do are missing. Probably easier to go this way. For instance, we use GPL our stuff. Uh on is going to that?

19:40

Speaker 2: Ugh. The top one is by a consultant. claude. So because we don't have enough front-end people it's uh like a major problem. And HTMX. So it's HTMX is a bulleton It's something we added so we have a separate app that's just to call HTMX so that we can turn it off and replace it with something else if we if we just need to. And we have just copied the structure. uh the other stuff because it started out isn't just an API and incident

20:27

Speaker 2: Base So this is the this is why I couldn't show this on the slide. Slightly more complex. So we have a um we have a preference here, store a preference in a preference database. And we have um search pixin which is um uh you can search on the um you have a search box on top of every um uh column And that's uses as search mixins, which is a single field. We can must produce new columns by subplassing search mix in and the

21:14

Speaker 2: top one here. It's in a list form. So I'm not there might be other questions, so I won't show you the preferences mixing PUs for the preferences page

21:26

Speaker 1: Thank you. Questions? More questions? Yes. Uh

21:34

Speaker 4: hello. Uh love the idea with the single form. I mean I it feels like you can pretty much uh generate any form field across the the site just with a few mixings What I would be interested to see is any nuggets of wisdom around permissioning. I mean right now the permissions are usually handled by the view. So if a form is supposed to be limited to some person, it's because the view is limited. But I've seen that you actually used uh at two URL entries and on the URL entry you pass both the model and the field instance and that view handles updating any kind of model with any kind of value that got generated. So If we go down that route, it's very hard to decide who can actually change a form

22:20

Speaker 4: field. So any ideas on that problem?

22:24

Speaker 2: Uh well, um um how comfortable are you with uh changing init on forms Because you could have um you could put uh each subclass, you could give them um yet another property that that's a role Person must have roll or grupp, something, something. And then you send in the person into the form. Then you can do a no render anything for this form for instance. That's a possibility. I've never needed to do it, but that's how I would do it.

23:03

Speaker 4: Nice idea. Thanks.

23:08

Speaker 1: So, Hanne, thank you so much for this talk and uh a new way looking at uh HMX forms using one form per field.

Presenters

Conference

DjangoCon Europe

April 15 - 17, 2026

Athens, Greece

Note: We understand that names change, people change, and bodies change. We respect each individual's journey and privacy. If you have any concerns about a video or need us to remove content, please don't hesitate to contact us. We will handle your request with care and promptly address any issues.

More videos from DjangoCon Europe