django-htmx
Extensions for using Django with htmx.
What it is and what it does
django-htmx bridges Django and htmx by providing server-side utilities to work with htmx's request patterns and response headers. It handles the integration layer that lets Django developers detect and respond to htmx requests, manage partial page updates, and leverage htmx's lightweight interactivity model within a Django application.
The package sits between Django's request/response cycle and htmx's client-side behavior, offering helpers to inspect incoming htmx requests and craft appropriate responses. It depends on Django and asgiref, integrating naturally into existing Django projects without requiring external services or complex setup.
Use it for:
- Build dynamic form validation and submission without full page reloads using htmx and Django views
- Implement progressive enhancement in Django templates by adding htmx attributes and handling partial renders
- Create real-time UI updates in Django dashboards by responding to htmx swap requests
- Add lightweight interactivity to Django applications without committing to a heavy JavaScript framework
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides Django integration utilities for htmx, enabling server-side support for htmx attributes and request handling within Django applications.
Yes. Active maintenance, no known vulnerabilities, permissive MIT license, and low install friction make it a safe choice. Suitable for Django projects targeting modern Python versions that want to integrate htmx without framework overhead.
Install
django-htmx on PyPI
pip
pip install django-htmxuv
uv add django-htmxpoetry
poetry add django-htmxInstalling django-htmx
Before you install
Low install friction with a pure Python wheel. Actively maintained with a release 9 days ago and 2003 repository stars. Requires Django and asgiref as runtime dependencies.
License in practice
MIT license permits commercial and private use with minimal restrictions, making it suitable for most projects.
Quickstart
pip install django-htmx
import django_htmx
# In Django view, detect htmx requests
if request.htmx:
return render(request, 'partial.html')
Requires Python 3.10 or later and Django 5.2+ as runtime dependencies.
Verify before relying
- Specific htmx features or request attributes the package exposes beyond basic integration
- Whether middleware is required or optional for core functionality
- Performance characteristics when handling high-volume htmx requests
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — asgiref, django |
| Maintenance | actively maintained — 9 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,670,958/month — #3,667 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_htmx-1.29.0-py3-none-any.whl
Keywords: Django
Tags
More Dynamic Content packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
soupsieveSoupsieve is a CSS selector library designed to…
permissive · top 100 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
FlaskFlask is a lightweight WSGI web application…
permissive · top 1,000 on PyPI
MakoMako compiles Python-embedded templates into…
permissive · top 1,000 on PyPI
litestar-htmxIntegrates HTMX into Litestar web applications,…
permissive · top 5,000 on PyPI
django-datatables-viewProvides a Django view base class that handles…
permissive · top 15,000 on PyPI
dj-datatables-viewProvides a Django base view for server-side…
permissive · top 15,000 on PyPI
django-markdownxDjango MarkdownX provides a Markdown editor…
permissive · top 15,000 on PyPI
django-admin-inline-paginator-plusAdds pagination to Django admin inline forms,…
permissive · top 15,000 on PyPI
jinja2-fragmentsRenders individual Jinja2 template blocks as…
permissive · top 15,000 on PyPI
python-fasthtmlFastHTML is a Python web framework that builds…
permissive · top 5,000 on PyPI
django-unfoldReplaces Django's default admin interface with…
permissive · top 5,000 on PyPI
django-stubs-extProvides runtime monkey-patching extensions for…
permissive · top 5,000 on PyPI
djangorestframework-datatablesAdds server-side Datatables support to Django…
permissive · top 15,000 on PyPI