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

Source: https://djangotv.com/videos/djangocon-europe/2026/djangocon-europe-2026-django-forms-in-the-age-of-htmx-the-single-field-form/
Date: 2026-07-20
Speakers: Speaker 1, Speaker 2, Speaker 3, Speaker 4

## Transcript

**Speaker 1:** [00:03] Thank you. No, let me introduce to you Hanne Moa. Let's welcome her. With a s nice applause. She is a devo developer, mostly you say. What I found really impressive using Python since version 1. 5 Yeah, that's yeah. I need to talk to you what has changed since 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.

**Speaker 2:** [00:37] Yes. Thank you. So this is the least interesting slide. I'm supposed to say something about 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 on my phone. So but that's the address I have to use. So but I have another address if you're interested if you want to contact later

[01:23] 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 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 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

[02:13] 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 change subsets of fields. So 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.

[03:01] And since well the users wanted paging and you could use the form wizard because they were very 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. 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 I do not recommend recursive forms. Really. I mean I've been there. Get me drunk, I can tell you about it I will not go into details.

[03:48] 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 when this time when you when you answered certain questions you would be sent to different questions. So it's a true and adventure style. And 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

[04:33] get complex really quickly. So the 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 Oof full form. This one is being deprecated because the people 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

[05:19] 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 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.

[06:08] 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 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

[06:57] And here's as you can see this one does not inherit from anything, it's just a 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, 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 open users, so I'll switch to this one. So this is your standard old style form.

[07:43] So add one. A B 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, and digital thing is what's in the JSON So you can look at the same thing.

[08:28] Oh. So you haven't seen the missing form here. This is 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

[09:14] Swagger mixed with this because I 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 shit. I'll go

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

[10:45] Time frame sense is the same. 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 to store it for us. So And as you can see, I mean we're working with networking. This is a dashboard that collects information from all our all our shit actually. And I could actually say it can connect any anything from anything. I've I've been using it for as a Pomodoro

[11:30] 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 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 Tailwind, DC UI, HTMX, and Dango52 right now You can use Django toss on 5v2, you just have to

[12:17] use another library. So back to the slides. What did I test? Oh, yeah, Mr. Wii, Mr. Y. No. So this is the code for the little demo I saw in the beginning.

[13:04] 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] 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 when we store the data in JSON. So 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 template with Django

[14:39] widget templates, you will not necessarily have all the context you need. So what you do is you use your own 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 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 if you want to put the actual get Ajax get on the directly on the thingy itself and it is a very difficult URL you can pre-compute it in the view and then when you make the form

[15:26] you can send in the URL you need. So second bonus if you go back here back This is 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 fooling around with the MRO and stuff

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

[17:01] More links for you. You've already seen the 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 oopsie That's the last slide.

**Speaker 1:** [17:29] So despite the

**Speaker 2:** [17:33] Why did it start? Why did it work in the beginning?

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

**Speaker 3:** [17:50] Hannah, thank you. That was super that's really interesting that the You have so many forms going on because it it's like one field per 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.

**Speaker 2:** [18:09] Yeah, well you have you have different subclasses for different needs So if I can find the Argus code. 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, user preference. And Well, because of the slide, this since the HTMX

[18:54] 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. On is going to that?

[19:40] Ugh. The top one is by a consultant. claude. So because we don't have enough front-end people it's 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. The other stuff because it started out isn't just an API and incident

[20:27] Base So this is the this is why I couldn't show this on the slide. Slightly more complex. So we have a we have a preference here, store a preference in a preference database. And we have search pixin which is you can search on the you have a search box on top of every 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] 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

**Speaker 1:** [21:26] Thank you. Questions? More questions? Yes.

**Speaker 4:** [21:34] hello. Love the idea with the single form. I mean I it feels like you can pretty much generate any form field across 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 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] field. So any ideas on that problem?

**Speaker 2:** [22:24] Well, how comfortable are you with changing init on forms Because you could have you could put each subclass, you could give them 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.

**Speaker 4:** [23:03] Nice idea. Thanks.

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