Skip to main content

Why this matters

A common way to build a web app today is to split it in two: a backend that serves a JSON API, and a separate React app that runs in the browser. That works, but for a lot of projects it is much more complicated than it needs to be.

This tutorial shows a simpler way. You keep a normal server-rendered web app and add interactivity with a few small tools.

Who this is for

  • Python web developers who want to be fullstack. If you already know Django (or Flask, or FastAPI), you can build interactive UIs without learning a whole new frontend ecosystem.
  • Junior developers who see “fullstack” as a big barrier. The frontend part of this stack is mostly HTML with a few extra attributes. There is much less to learn before you can build a complete feature on your own.
  • People leading fullstack teams. A simpler stack means more of your team can build features end to end, with less hand-holding and fewer handoffs.
  • Anyone starting something new. Fewer moving parts means you can get going quickly and spend your time on the actual product.
  • Anyone who cares about fast, lightweight frontends. These tools are tiny, so pages load quickly, use little network data, and work well on older and low-powered devices.

Less complexity

With a separate React frontend, building one feature can mean touching a database model, an API endpoint, a serializer, a frontend data-fetching layer, frontend state, and the components that display it. That’s a lot of context switching, and a lot of places for things to go wrong.

With the tools in this tutorial:

  • There is no JavaScript build step. HTMX, Alpine.js and Tailwind are all loaded from a CDN.
  • There is no separate frontend app to run, deploy or keep in sync.
  • There is no JSON API layer just for your own frontend. The server sends HTML.
  • There is no duplicated state between the browser and the server.

The server stays in charge

Your logic, validation and templates all live in one place: the Django app. When something changes, the server renders the new HTML and HTMX swaps it into the page.

This means a single developer can build a whole feature, from the database to what the user sees, using one language and one codebase.

The right tool for most apps

Many web apps are mostly forms, lists, tables and buttons. They don’t need a single page application. HTMX and Alpine.js can handle a surprising amount, including things like drag-and-drop boards, inline editing and live updates.

React and similar frameworks are still useful for some things, like highly interactive apps that need a lot of state in the browser (think design tools or spreadsheets). But it’s worth reaching for the simplest tool that can do the job, and only adding complexity when you need it.

Testing with Playwright

Once your pages are interactive, you need to know they actually work. Unit tests on your views can’t tell you whether clicking a checkbox really updates the page.

Playwright drives a real browser, so your tests can click things and check what the user sees. And because the frontend lives inside the Django app, those tests sit right next to the rest of your tests.

A real example

This approach isn’t just theory. It’s been used on a real project with a junior-heavy team, where it made everyone on the team more productive. You can read about it here: An HTMX success story.