Installation¶
Requirements¶
Python 3.9 to 3.13 supported.
Django 4.2 to 5.2 supported.
Installation¶
Install with pip:
python -m pip install django-htmx
Add django-htmx to your
INSTALLED_APPS
:INSTALLED_APPS = [ ..., "django_htmx", ..., ]
Add the middleware:
MIDDLEWARE = [ ..., "django_htmx.middleware.HtmxMiddleware", ..., ]
The middleware adds
request.htmx
, as described in Middleware.Add htmx and the django-htmx extension script to your pages with a template tag, available for Django templates and Jinja2. In the typical case, with Django templates:
{% load django_htmx %} <!doctype html> <html> <head> ... {% htmx_script %} </head> <body> ... </body> </html>