HTMX + Django

IntermediateWeb App

Django views with HTMX for dynamic UIs without a JS framework.

Published 27 September 2026Last updated 16 October 2026

Core Tools
HTMX
HTMX
Django
Django
Python
Python
HTML
HTML
CSS
CSS
Database
PostgreSQL
MySQL
MariaDB
Hosting
Railway
Render
Hetzner
Fly.io
DigitalOcean

About HTMX + Django

HTMX + Django brings interactivity to server-rendered pages without adding a JavaScript framework. HTMX is a small library (~14KB) that lets HTML elements trigger HTTP requests and swap parts of the DOM with the server's response. The result looks and feels like a single-page app (instant search, inline editing, modal dialogs), but the logic stays in Django views and the DOM is always updated with real server-rendered HTML, not JSON deserialized by JavaScript.

Django provides the full backend: ORM, auth, forms, migrations, and admin. Tailwind CSS is available as an optional addition for utility-class styling. The combination removes the largest source of complexity in modern web development, the boundary between a REST API and a JavaScript frontend, while preserving the interactivity users expect. A search input with hx-get triggers a GET request on every keystroke; Django returns an HTML fragment; HTMX inserts it into the results container. No Redux, no React state, no serialisation round-trip.

This stack is particularly well-suited for teams that are comfortable with Python and want to avoid the context-switching cost of maintaining a separate JavaScript codebase. The primary constraint is that complex client-side state (drag-and-drop, rich text editors, canvas) still needs JavaScript: HTMX handles server-driven interactions, not client-driven ones.

Key Features

  • ✓HTMX triggers HTTP requests from any HTML element, with no JavaScript required by the developer
  • ✓Django returns HTML fragments that HTMX swaps into the DOM in place
  • ✓Server-side rendering with Django templates: full-page and partial updates use the same view layer
  • ✓Tailwind CSS for utility-first styling without a custom CSS architecture
  • ✓WebSocket support via Django Channels for real-time push notifications
  • ✓Django admin, ORM, and auth remain fully intact alongside the HTMX layer

When to Use HTMX + Django

  • Internal dashboards with live-updating tables and filters
  • Data entry forms with inline validation and dependent field logic
  • Admin-style interfaces where React would be overkill
  • Content management tools with inline editing
  • Search-heavy pages with instant results

Pros

  • Eliminates the API/frontend boundary: no JSON serialisation, no CORS, no client-side state management
  • Django developers can add interactivity without learning React or Vue
  • HTMX's entire mental model fits in an afternoon, keeping ongoing cognitive load low
  • Server-side rendering is better for SEO and initial page load than client-rendered SPAs

Cons

  • Rich client-side interactions (drag-and-drop, canvas, offline mode) still require JavaScript
  • Network latency is visible on every interaction, so it's unsuitable for sub-100ms UI feedback loops
  • Harder to build a mobile app on top of this stack compared to a REST or GraphQL API

Database Options for HTMX + Django

PostgreSQL

HTMX + Django with PostgreSQL

The standard choice: a full PostgreSQL instance on a managed host or your own server, connected from Django via its built-in ORM, with complete control over configuration and extensions.

MySQL

HTMX + Django with MySQL

MySQL is one of Django's four officially documented database backends: same ORM, same migrations, no code changes beyond the connection string. Common when the host, team, or existing infrastructure is already MySQL-based.

MariaDB

HTMX + Django with MariaDB

Django officially supports MariaDB 10.4+ through the same MySQL backend driver, a drop-in swap for MySQL with no separate configuration. Pick this over MySQL specifically for MariaDB's open licensing, or if that's what your hosting provider defaults to.

These are highlighted picks. To see all the tools, check the Databases category.

Hosting Options for HTMX + Django

Railway

Deploy HTMX + Django on Railway

A container-based platform where the whole Django + HTMX app deploys as a persistent service, a natural fit for a WSGI/ASGI process holding a live Postgres connection pool. No free tier: the Hobby plan starts around $5/mo in usage credit, plus usage-based billing for CPU, memory, and network. Auto-deploys on push, and has no CDN of its own.

Render

Deploy HTMX + Django on Render

The same persistent-service model as Railway, with a genuinely free tier for small Django apps, built-in cron jobs, and its own CDN for static assets. Free-tier services spin down after inactivity; predictable always-on pricing starts around $7/mo.

Hetzner

Deploy HTMX + Django on Hetzner

A self-hosted VPS running the whole Django + HTMX app yourself, at the price of managing deployment and updates. Entry-level instances start around €4-5/mo, the cheapest option here, though there's no bundled CDN.

Fly.io

Deploy HTMX + Django on Fly.io

Runs the Django app as a container close to users across multiple regions, useful if latency to a geographically spread user base matters more than raw cost. Billing is usage-based with only a small free allowance, and there's no dedicated static-asset CDN either.

DigitalOcean

Deploy HTMX + Django on DigitalOcean

A managed VPS or App Platform deployment with predictable flat-rate pricing, starting around $4-6/mo for a basic Droplet or about $5/mo for App Platform's smallest tier. Neither bundles a CDN by default, though DigitalOcean sells one (Spaces CDN) separately if needed.

These are highlighted picks. To see all the tools, check the Hosting & Cloud category.

HTMX + Django Add-ons

Each addition below extends this stack with a capability the base stack works fine without. None are required: include the ones your product actually needs when building this stack, and skip the rest.

App features and services

5

What your users see and use: sign-in, payments, email, and the look and feel of the interface.

Authentication Add-ons

Add authentication when the app needs user accounts — sign-up, login, and data scoped to a specific user instead of a fully open app.

django-allauth
HTMX + Django with django-allauth

The ecosystem-standard third-party package for Django authentication, adding social login (Google, GitHub, and dozens more), email verification, and MFA on top of Django's own built-in auth system. The default here because it's what most Django projects reach for once they need more than basic username/password sessions.

Auth0
HTMX + Django with Auth0

A hosted identity platform with an official Python SDK for verifying sessions in Django views and middleware, worth it over django-allauth if you'd rather not self-host the auth logic at all, or need enterprise features like SSO that django-allauth doesn't cover.

These are highlighted picks. To see all the tools, check the Authentication category.

Email Add-ons

Add email when the app needs to send account verification, password reset, or notification messages.

Resend
HTMX + Django with Resend

A transactional email API for account verification, password resets, and notification emails, sent via Resend's official Python SDK from a Django view, with a free tier for getting started.

SendGrid
HTMX + Django with SendGrid

The established high-volume choice, with dedicated IP addresses and deliverability tooling for apps sending at serious scale. No permanent free plan (a 60-day trial, then paid tiers), so it earns its slot when volume and deliverability matter more than upfront cost.

Brevo
HTMX + Django with Brevo

An all-in-one platform combining the transactional email API with marketing campaigns, a built-in CRM, and SMS from the same dashboard. A permanent free tier of 300 emails a day with no card required makes it an easy starting pick for an early-stage app.

Payments Add-ons

Add payments when the product is ready to charge for subscriptions or one-time purchases.

Stripe
HTMX + Django with Stripe

Adds subscription billing, one-time checkout, and invoicing via Stripe's hosted Checkout or embedded Elements, with Django handling webhook verification and API calls server-side. The stack works fully without it; add this once the product is ready to charge for something.

Styling Add-ons

Add styling when you want a component or utility-class system to build the UI faster than hand-writing CSS from scratch.

Tailwind CSS
HTMX + Django with Tailwind CSS

A utility-class CSS framework: styles are composed directly in markup via class names instead of writing separate stylesheet files. The default styling choice bundled by most modern framework CLIs (create-next-app, create-vue, the SvelteKit and Astro starters all offer it), and the base layer shadcn/ui components are built on when that's loaded into the catalog in the future.

Bootstrap
HTMX + Django with Bootstrap

Ready-made components and a grid for Django templates, with the crispy-forms Bootstrap 5 pack rendering forms and their validation errors in Bootstrap markup. A common choice for admin-style interfaces. Pick it or Tailwind, since the two overlap on spacing and layout classes.

These are highlighted picks. To see all the tools, check the CSS Frameworks category.

Interactivity Add-ons

Add client-side interactivity when you want local UI state — toggles, modals, dropdowns, tabs — without a full JS framework or an extra server round trip.

Alpine.js
HTMX + Django with Alpine.js

Alpine.js adds lightweight, declarative client-side interactivity on top of this stack's HTMX-driven Django pages: toggling a mobile menu, showing a modal, or switching an active tab, all without triggering a server round trip HTMX would otherwise need. It is included via a script tag, with behavior written as HTML attributes (x-data, x-show, x-on) rather than a build step, keeping the stack's zero-bundler approach intact.

These are highlighted picks. To see all the tools, check the HTML-first Frameworks category.

Under the hood (backend)

3

Services your users never see, which store data and keep the app fast and reliable.

Object Storage Add-ons

Add object storage when your app accepts file uploads or produces files, such as avatars, documents, images, and exports, and those files should live outside your database and server disk.

Cloudflare R2
HTMX + Django with Cloudflare R2

S3-compatible object storage with no egress fees, so serving uploads, images, and exports costs only for storage and operations. Django reaches it through django-storages' S3 backend with a custom endpoint where needed, so FileField and ImageField uploads land in the bucket instead of the server disk, and the keys stay in Django settings. The 10 GB free tier covers an early product.

Amazon S3
HTMX + Django with Amazon S3

The reference object store and the API the others copy, with the most storage classes, regional controls, and lifecycle rules. Django reaches it through django-storages' S3 backend with a custom endpoint where needed, so FileField and ImageField uploads land in the bucket instead of the server disk, and the keys stay in Django settings. It fits best when the rest of the app already runs on AWS, though data transfer out is billed.

Backblaze B2
HTMX + Django with Backblaze B2

An S3-compatible store at roughly a third of S3 Standard's storage price, a fit for backups and large media libraries. Django reaches it through django-storages' S3 backend with a custom endpoint where needed, so FileField and ImageField uploads land in the bucket instead of the server disk, and the keys stay in Django settings. Egress is free up to three times the stored data, and a CDN in front of a public bucket covers heavier delivery.

These are highlighted picks. To see all the tools, check the Object Storage category.

Caching Add-ons

Add caching when the same reads or computations repeat and you want them answered from memory: a cache holds hot data, shared counters, and session state in front of a database or an upstream API.

Redis
HTMX + Django with Redis

Django's cache framework with django-redis as the backend: cache_page caches whole views, the cache template tag caches fragments of the partials HTMX swaps in, and sessions can live in Redis instead of the database. Configuring it is one CACHES entry in settings. PostgreSQL already keeps frequently read data in memory, so add Redis when the same pages and fragments are rendered often enough to show up in response times.

Background Jobs Add-ons

Add background jobs when work should run outside the request and must survive restarts, retry on failure, or run on a schedule: a separate worker takes it from a queue. Small fire-and-forget jobs can often stay in your framework's built-in background tasks.

Celery
HTMX + Django with Celery

Django 6.0's built-in Tasks framework lets views enqueue background work, but it ships no production worker. Celery is the established one: an HTMX request queues a task and returns a progress fragment at once, the fragment polls until the worker finishes, and delay_on_commit makes sure the task runs only after the database transaction commits. django-celery-beat keeps schedules editable in the Django admin. Celery needs a broker, usually Redis (the instance used for caching can serve both), or RabbitMQ.

These are highlighted picks. To see all the tools, check the Message Queues & Background Jobs category.

Build and deploy

2

Testing, packaging, and shipping your code on every change.

CI/CD Add-ons

Add CI/CD when you want a dedicated pipeline for running tests, linting, or multi-stage builds before a deploy goes out. Many hosting platforms already redeploy automatically on every push on their own — a CI/CD tool adds the most value on top of that by gating the deploy on a passing test suite, and matters even more when the hosting choice does not auto-deploy at all, such as a self-hosted server.

GitHub Actions
HTMX + Django with GitHub Actions

Runs the test suite and triggers deployments on every push, directly from the same GitHub repo the code already lives in, with no separate CI service to configure.

GitLab CI/CD
HTMX + Django with GitLab CI/CD

GitLab's built-in CI/CD system, configured via .gitlab-ci.yml in the repository, the natural pick if the project's code lives on GitLab (self-hosted or gitlab.com) rather than GitHub, with the same YAML-pipeline model as GitHub Actions.

These are highlighted picks. To see all the tools, check the CI/CD Pipelines category.

Containerization Add-ons

Add containerization when you want the app packaged the same way across local development, staging, and production, or need to deploy somewhere that isn't a managed serverless platform.

Docker
HTMX + Django with Docker

Packages the whole Django + HTMX app into a container image for consistent local development and deployment, independent of the hosting platform chosen above.

These are highlighted picks. To see all the tools, check the Containerization category.

Monitoring and analytics

2

For you rather than your users: what people do in the app, what breaks, and why a model answered the way it did.

Observability Add-ons

Add observability when you want to catch errors and performance regressions in production before users have to report them.

Sentry
HTMX + Django with Sentry

Error tracking and performance monitoring with a dedicated Sentry Django integration, covering both view-level errors and template-rendering issues. Open-source with a self-hosted path, alongside its own managed cloud.

Datadog
HTMX + Django with Datadog

A broader observability platform covering APM, infrastructure metrics, and log management in one dashboard, useful once a team is already running other services worth monitoring alongside this app. Managed-only, with pricing that scales by host and usage rather than Sentry's per-error volume.

These are highlighted picks. To see all the tools, check the Infrastructure & APM category.

Analytics Add-ons

Add analytics when you want to measure traffic, track visitor behavior, or understand how people actually use the product.

PostHog
HTMX + Django with PostHog

An all-in-one product analytics platform: event tracking, session replay, feature flags, and A/B testing in one SDK. The richest feature set if you want more than pageviews.

Google Analytics
HTMX + Django with Google Analytics

The industry-standard, free analytics platform, with native Google Ads and Search Console integration. Requires a cookie consent banner in most jurisdictions (GDPR/CCPA), and all data lives on Google's infrastructure, the tradeoff the other three picks were built to avoid.

Plausible Analytics
HTMX + Django with Plausible Analytics

A lightweight, privacy-first analytics tool with no cookie banner required. A good fit for simple traffic metrics without PostHog's broader feature surface.

Umami
HTMX + Django with Umami

Open-source and self-hostable, keeping analytics data on infrastructure you control. Pairs naturally with the self-hosted Hetzner hosting option above if you want to avoid a third-party analytics vendor entirely.

These are highlighted picks. To see all the tools, check the Web & Product Analytics category.

Frequently Asked Questions about HTMX + Django

How does this compare to the Django + HTML Templates stack (without HTMX)?

The core Django app is identical to Django + HTML Templates: same ORM, same views, same templates. HTMX adds partial-page swaps for specific interactions (a form that submits without a full reload, a list that filters live) without introducing a JS framework or build step. Add it once full-page reloads start feeling slow for common interactions; skip it for a mostly-static site.

How does this compare to the HTMX + FastAPI and HTMX + Flask stacks?

All three pair HTMX with a different Python backend. Here Django brings a built-in ORM, admin panel, and auth system; HTMX + FastAPI brings FastAPI's async performance and automatic API docs; HTMX + Flask brings Flask's minimal, unopinionated core. Pick based on which backend framework fits the rest of the project; HTMX itself works the same way on all three.

Should I use django-allauth, Auth0, or is Django's built-in auth enough?

Django's built-in auth system covers basic sessions, login, and permissions out of the box, plenty for an internal tool or a simple app. django-allauth is the ecosystem-standard upgrade once you need social login, email verification, or MFA, self-hosted and free. Auth0 is worth it instead if you'd rather not run the auth logic yourself at all.

What's the cheapest way to run this stack?

Self-hosted PostgreSQL and skipping the paid addition tools cost nothing beyond hosting. Every hosting option here (Railway, Render, Fly.io, DigitalOcean) charges from day one for an always-on process, so expect at least about $5/mo once you're past local development.

Scores

Popularity3/5

Established

Django is well-established, but pairing it with HTMX specifically is a smaller, if fast-growing, pattern compared to a JS framework frontend — genuinely capable for the "server-rendered but interactive" niche, not yet a mainstream default.

Learning Curve2/5

Easy

Django's conventions carry over directly, and HTMX adds only a handful of HTML attributes (hx-get, hx-post, hx-swap) rather than a new templating language or build step. Genuinely one of the faster paths to interactive UI for a Django developer.

Flexibility3/5

Configurable

Django's ORM and template engine are opinionated about project structure, and HTMX itself just swaps HTML fragments — it doesn't introduce its own state-management or component model to add flexibility on top of. Consistent and predictable, not a highly configurable setup.

Performance3/5

Average

HTMX's partial-page swaps avoid a full page reload for most interactions, which feels faster than plain server-rendered Django alone, but each interaction is still a server round-trip — no client-side state or optimistic updates the way a JS framework would provide.

Portability3/5

Some lock-in

Django and HTMX are both open-source with no vendor lock-in, portable to any Python-capable host. The main migration cost is Django's own ORM/template conventions — HTMX itself adds very little coupling since it's just HTML attributes.

Tools in the HTMX + Django Stack

Frontend Frameworks

Backend Frameworks

Programming Languages

Database (choose one)

Hosting (choose one)

Add-ons (optional — add any, or none)
App features and services

Authentication

Email

Payments

Styling

Interactivity

Under the hood (backend)

Object Storage

Caching

Background Jobs

Build and deploy

CI/CD

Containerization

Monitoring and analytics

Observability

Analytics

HTMX + Django Pricing

From ~$5/mo Free to start

Every piece of this stack (Django, HTMX, Tailwind CSS, Python and PostgreSQL) is open-source and free. HTMX adds interactivity without a separate JavaScript build or frontend host, so you only pay for one app server and a database: about $5–20/mo on Railway, Render, Fly.io or Hetzner, with managed Postgres from roughly $6–15/mo if you don't self-host.

Core toolsFree (open source)

Django, HTMX, Tailwind CSS, Python and PostgreSQL are free.

Hosting$5–20/mo

A single app server on Railway, Render, Fly.io, Hetzner or DigitalOcean; free tiers for testing.

Database (PostgreSQL)Free–$15/mo

Self-host for free, or use managed Postgres from about $6–15/mo.