Wishlist granted: HTMX without betraying your Django views
summary
Built a wishlist for an aircraft-parts marketplace by keeping existing Django models and views and adding HTMX + Django partials so actions happen without full-page reloads. Changes are small: add Django-HTMX middleware, serve template fragments via conditional get_template_name, and use hx-post, hx-get, hx-target, hx-swap on forms and links. Handles CSRF on non-form posts, uses HTMX client-side events to refresh distant nav counts, and converts redirects to HttpResponseClientRedirect (or middleware) so session expirations don’t swap full login pages. Tests use Django test client with HX headers.
AI-written summary · about
chapters (14)
- 0:00Introduction and motivation
- 7:47Baseline wish list demo
- 8:55Recipe ingredients explained
- 15:27Setting up HTMX and Django
- 18:23First HTMX swap example
- 22:23Adding items with HTMX
- 25:00Handling POST requests
- 27:14Demo of wish list operations
- 29:33Renaming wish lists
- 31:08Using HTMX events
- 34:27Session expiration handling
- 36:59Live site demonstration
- 38:32Closing remarks and tradeoffs
- 41:09Q&A session
