Recap
Over five goals, we turned a todo list that only showed items into one you can tick off, sort and expand, with tests that check it all works. This page looks back at what we built and which tool did each job.
What modern frontends need
In What modern frontends need, we listed what a frontend actually has to do. Here’s how we covered each one:
- Render HTML. Django renders the page from templates. We split pieces of the page into partials, like
partials/todo_item.html, so the server can render them on their own. - React to events. HTMX’s
hx-triggersends a request when a checkbox is clicked (goal 1). Alpine’sx-on:clickflips a value when an arrow is clicked (goal 4). - Send data to the backend. HTMX’s
hx-postsaves the checkbox change, andhx-headerssends Django’s CSRF token with it (goal 1). - Re-render parts of the page when needed. The server sends back HTML, and
hx-targetandhx-swapsay where it goes. First one todo item (goal 2), then the whole list, so it stays sorted (goal 3). - Sometimes, show live updates sent by the backend. We skipped this one, as promised in What to expect. HTMX can do it too.
- Sometimes, manage a bit of state in the browser. Alpine’s
x-datagives each todo item its ownopenstate, andx-showshows the description when it’s open (goal 4).
On top of that, Tailwind’s utility classes styled everything, and Playwright drove a real browser to test the features we built (goal 5).
What we didn’t need
Look at what’s missing from the project:
- No JSON API. The server sends HTML, so there’s no data to serialise and no frontend code that depends on the shape of that data.
- No build step. HTMX, Alpine.js and Tailwind load from a CDN with a
<script>tag. - One codebase. The views, templates and tests all live in the same Django project.
- One kind of test. Our Playwright tests are ordinary pytest tests. They click through the real app, so they check the templates, the views and the database together.
Which tool for which job
When you add a feature of your own, ask where it needs to happen:
- It needs the server (saving, loading or anything the database knows about): use HTMX, and have the server send back HTML.
- It only changes what’s shown in the browser (opening, closing, toggling): use Alpine.js.
- It changes how things look: use Tailwind classes.
- You want to know it still works next time: write a Playwright test.