htmx-patterns — how to use htmx-patterns with Django how to use htmx-patterns with Django, what is htmx-patterns, htmx-patterns alternative to AJAX, htmx-patterns vs React, htmx-patterns install guide, htmx-patterns setup for Django developers

v1.0.0
GitHub

About this Skill

Perfect for Web Development Agents needing dynamic HTML fragment rendering and progressive enhancement with Django. htmx-patterns is a set of techniques for using HTMX with Django, emphasizing server-rendered HTML fragments, partial templates, and minimal client-side complexity.

Features

Server renders HTML fragments, not JSON, for efficient data transfer
Utilizes partial templates (_partial.html) for HTMX responses
Employs progressive enhancement for pages that work without JavaScript
Leverages django-htmx middleware for HTMX detection in views
Uses request.htmx for conditional rendering of templates

# Core Topics

Travis-Gilbert Travis-Gilbert
[0]
[0]
Updated: 3/4/2026

Quality Score

Top 5%
33
Excellent
Based on code quality & docs
Installation
SYS Universal Install (Auto-Detect)
> npx killer-skills add Travis-Gilbert/apply.thelandbank.org/htmx-patterns
Supports 18+ Platforms
Cursor
Windsurf
VS Code
Trae
Claude
OpenClaw
+12 more

Agent Capability Analysis

The htmx-patterns MCP Server by Travis-Gilbert is an open-source Community integration for Claude and other AI agents, enabling seamless task automation and capability expansion. Optimized for how to use htmx-patterns with Django, what is htmx-patterns, htmx-patterns alternative to AJAX.

Ideal Agent Persona

Perfect for Web Development Agents needing dynamic HTML fragment rendering and progressive enhancement with Django.

Core Value

Empowers agents to integrate HTMX with Django, enabling server-rendered HTML fragments and progressive enhancement using partial templates and minimal client-side complexity, leveraging `django-htmx` middleware and `request.htmx` detection.

Capabilities Granted for htmx-patterns MCP Server

Rendering dynamic HTML fragments for web applications
Implementing progressive enhancement for improved user experience
Detecting HTMX requests in Django views using `request.htmx`

! Prerequisites & Limits

  • Requires Django framework
  • Needs `django-htmx` middleware installation
  • Limited to server-side rendering with HTMX
Project
SKILL.md
2.5 KB
.cursorrules
1.2 KB
package.json
240 B
Ready
UTF-8

# Tags

[No tags]
SKILL.md
Readonly

HTMX Patterns for Django

Core Philosophy

  • Server renders HTML fragments, not JSON
  • Partial templates (_partial.html) for HTMX responses
  • Progressive enhancement — pages work without JS, HTMX enhances UX
  • Minimal client-side complexity — let the server do the heavy lifting

HTMX Detection in Views

With django-htmx middleware installed, use request.htmx:

python
1def my_view(request): 2 context = {...} 3 if request.htmx: 4 return render(request, "app/_partial.html", context) 5 return render(request, "app/full_page.html", context)

Form Handling Pattern

python
1def create_view(request): 2 if request.method == "POST": 3 form = MyForm(request.POST) 4 if form.is_valid(): 5 obj = form.save() 6 if request.htmx: 7 return render(request, "app/_item.html", {"item": obj}) 8 return redirect("app:list") 9 # Return form WITH errors for HTMX 10 if request.htmx: 11 return render(request, "app/_form.html", {"form": form}) 12 else: 13 form = MyForm() 14 return render(request, "app/create.html", {"form": form})

Template Organization

  • Partials: _partial.html (underscore prefix) — HTML fragments only
  • Full pages: page.html — extends base.html, includes partials
  • Each partial = one logical UI component

CSRF Configuration

Add to <body> tag in base template — all HTMX requests include it automatically:

html
1<body hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'>

Response Headers

HeaderPurposeExample
HX-TriggerTrigger client-side eventsresponse["HX-Trigger"] = "applicationCreated"
HX-RedirectClient-side redirectresponse["HX-Redirect"] = reverse("app:detail", args=[obj.pk])
HX-RetargetOverride target from serverresponse["HX-Retarget"] = "#main"
HX-RefreshForce full page refreshresponse["HX-Refresh"] = "true"

UX Requirements

  • Always use hx-indicator for loading states
  • Always use hx-disabled-elt="this" to prevent double submissions
  • Always return form errors in partial templates on validation failure
  • Always provide feedback via Django messages or response content

Common Pitfalls

  • Missing loading indicators — users click multiple times
  • Returning full pages instead of partials for HTMX requests
  • Not handling form errors — only handling the success case
  • N+1 queries — HTMX views need select_related() / prefetch_related() too

Related Skills

Looking for an alternative to htmx-patterns or building a Community AI Agent? Explore these related open-source MCP Servers.

View All

widget-generator

Logo of f
f

widget-generator is an open-source AI agent skill for creating widget plugins that are injected into prompt feeds on prompts.chat. It supports two rendering modes: standard prompt widgets using default PromptCard styling and custom render widgets built as full React components.

149.6k
0
Design

linear

Logo of lobehub
lobehub

Linear is a workflow management system that enables multi-agent collaboration, effortless agent team design, and introduces agents as the unit of work interaction.

73.4k
0
Communication

testing

Logo of lobehub
lobehub

Testing is a process for verifying AI agent functionality using commands like bunx vitest run and optimizing workflows with targeted test runs.

73.3k
0
Communication

chat-sdk

Logo of lobehub
lobehub

chat-sdk is a unified TypeScript SDK for building chat bots across multiple platforms, providing a single interface for deploying bot logic.

73.0k
0
Communication