django-htmx-modal-popup-loveliness django htmx modal popup loveliness


I thought to share a pattern I’ve been using recently, for providing modal popups, via HTMX.

I’m using Bootstrap5 but this is straightforward to implement in whichever framework.

As ever, HTMX has a wonderful example ( ) of how to do this in the frontend (as well any many other examples ( ) !).

Here though I show how I’m doing things both front and backend, and specifically for Django .

I’m doing things a little differently than the official example, cutting out some lines of code.

You can find the repo (including sqlite db – admin username and password is ‘me’) here: