Installation

Install the core package from PyPI:

python -m pip install django-htmx-views

Install the optional linked-select integration when it is needed:

python -m pip install "django-htmx-views[linked-selects]"

Install the optional Bootstrap 5 integration, including django-bootstrap5, when using the Bootstrap template components:

python -m pip install "django-htmx-views[bootstrap5]"

Django settings

Add the package to INSTALLED_APPS and enable the django-htmx middleware:

INSTALLED_APPS = [
    # ...
    "htmx_views",
]

MIDDLEWARE = [
    # ...
    "django_htmx.middleware.HtmxMiddleware",
]

Add "django_bootstrap5" to INSTALLED_APPS as well when using its form, button, CSS, or JavaScript template tags. The structural tags supplied by htmx_views do not load Bootstrap assets automatically.

Migrating an existing application

  1. Install the package and add htmx_views to INSTALLED_APPS.

  2. Replace imports beginning with apps.htmx_views with htmx_views.

  3. Include htmx_views.urls if the application uses linked selects.

  4. Run the consuming application’s tests before removing its copied apps/htmx_views directory.