finds.dev

adamchainz/django-htmx

Extensions for using Django with htmx.

View on GitHubHomepage ↗

★ 1,992JavaScriptMITupdated Jun 2026

// the take

A thin Django integration layer for htmx — middleware that annotates request objects with htmx metadata, response helpers for triggering htmx events server-side, and a template tag that renders the correct script tag. Aimed at Django developers who want to add htmx interactivity without writing much JavaScript. The scope is intentionally narrow.

The middleware approach is the right call — attaching `request.htmx` with typed properties (is htmx request, current URL, trigger element, etc.) means you can branch view logic cleanly without parsing headers manually. The response helpers for `HX-Trigger` and friends handle the JSON serialization edge cases that catch people out. 100% test coverage and active maintenance (last push two weeks ago) are real signals, not just badges. The bundled example project covers the non-obvious cases like CSRF handling with htmx, which is where most Django+htmx setups silently break.

The library ships htmx.js itself, which means you're pulling a Python package to stay in sync with a JavaScript library's releases — two separate upgrade cycles that will drift. No built-in support for htmx extensions beyond what the example project scripts in manually. The template tag API is minimal to the point where it adds almost no value over a plain `{% load static %}` include; feels like it exists mostly for completeness. Documentation lives on Read the Docs but the actual middleware and http modules are small enough that most people will just read the source — the docs layer may not be worth the maintenance overhead.

We read the README, the directory tree and a key source file in June 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
1,992
Forks
154
Language
JavaScript
License
MIT
Last commit
14 Jun 2026

// nearby

If django-htmx isn't quite it.

All repos →