htmx is great

I build a small application, and for the first time I used htmx. Unfortunately I must not show you anything, but the htmx library (combined with Bootstrap5) is fun.

1 Like

Did you use Django for the backend?

If so, was there anything noteworthy about your app? Any strange things with integrating Django and htmx?

I’ve had some interest in htmx too, but I haven’t hit a use case for it yet so I’ve not tried it out.

1 Like

htmx works like documented. And questions at Stackoverflow with this tag get answered soon.

I had one small issue: If you want a snippet to do a full-page reload, then the server should send a special http header. But the status code should be 200 (not 302 like in my first implementation).

I documented this here: https://stackoverflow.com/a/65569741/633961

For me htmx is like a straight line. The shortest way to get from A to B. Don’t ask me why it took me so long that to discover that something like this is missing.

1 Like

I am happy to see HTMX getting some love here. I had a short conversation on reddit about it. Seems there is a lot more interest, so I started a repo to illustrate basic use cases and code samples on using HTMX and Django.

I use IntercoolerJS, the precursor to HTMX, quite extensively on my projects. Conceptually they are the same. The main difference is a bit of syntax and dropping of the jQUERY dependency.

I added htmx to my project and wrote up a quick article to show the configuration I needed for Django (to handle CSRF) as well as an example.

6 Likes

Thank you,

I have created a simple django app to for those who want to play with htmx:

1 Like

GitHub - adamchainz/django-htmx: Extensions for using Django with htmx. by @adamchainz might be a useful library to integrate Django and htmx in case folks haven’t seen it before.

1 Like

I also have a couple example use cases in the example app in the django-htmx repo.

1 Like

I recently created a small app called AniQuote that generates random anime quotes, primarily using Django and htmx. I wanted to test out htmx and I have to admit htmx is really amazing. I was able to make the site interactive with little to no JavaScript used!

1 Like

Please spread the good news, so more people can enjoy it.

Hello good people! I am reading this now in 2023 and want to ask, are you still using HTMX, can it be used in live projects? Did it evolve more in the past 2 years?
Thank you

I’m still using it as a major component of the systems I’m working on. I wouldn’t even be attempting to do what I’m doing now without it.

As a project, it’s still being actively developed. It’s still evolving and improving.

Yes, I’m still as thrilled with it as I have been for about the past 18 months.

1 Like

Thank you Ken! I am trying to decide should i start learning it and do people use it in production projects, considering there is not much info about it, but from i tried to do, it looks very cool and promising

I have also been using HTMX in some of my last projects, both personal and for clients.

Works like a charm.

You do need to structure your views and templates in a different way, but worth the effort.

Thank you, do you know a good resource to start learning how htmx works with django?

Base HTMX is really straight-forward. An AJAX request is issued based upon something being triggered in the client. That AJAX request is expecting to have HTML returned. HTMX then replaces the appropriate HTML in the document with the HTML returned by the server.

What that means from Django’s perspective is that generally, you will have a view that renders a template - but unlike the full page templates you’re used to rendering, these templates will only end up rendering div elements.

If you want to go a more sophisticated route, check out the django-htmx package referenced above.

When I was learning it, I followed this tutorial series from BugBytes: Django and HTMX

1 Like