htmx django
via PatrickJS/awesome-cursorrules
HTMX development with Django integration best practices and patterns.
What is htmx django?
This rule provides guidance for building interactive web applications by combining HTMX with Django. Use it when building dynamic, partial-page-update features in Django projects, leveraging Django's template system, forms, ORM, and class-based views alongside HTMX attributes.
- Integrate HTMX attributes with Django's template system
- Handle forms and CSRF protection using Django's built-in features
- Route HTMX requests through Django's URL routing and class-based views
- Validate form submissions with Django's form validation
- Manage database operations via Django ORM within HTMX responses
- Structure projects following Django conventions with templates and static assets
Applies to
File patterns this rule matches.
Rule definition (reference)
Source of truth, from the repository.
// HTMX with Django .cursorrules
// HTMX and Django best practices
const htmxDjangoBestPractices = [ "Use Django's template system with HTMX attributes", "Implement Django forms for form handling", "Utilize Django's URL routing system", "Use Django's class-based views for HTMX responses", "Implement Django ORM for database operations", "Utilize Django's middleware for request/response processing", ];
// Folder structure
const folderStructure = project_name/ app_name/ templates/ static/ css/ js/ models.py views.py urls.py project_name/ settings.py urls.py manage.py;
// Additional instructions
const additionalInstructions = `
- Use Django's template tags with HTMX attributes
- Implement proper CSRF protection with Django's built-in features
- Utilize Django's HttpResponse for HTMX-specific responses
- Use Django's form validation for HTMX requests
- Implement proper error handling and logging
- Follow Django's best practices for project structure
- Use Django's staticfiles app for managing static assets `;
Related rules
HTMX development with Flask integration best practices and patterns.
Go development with HTMX for server-side rendered interactive web applications.
Go Fiber best practices for building HTMX-driven web applications.
Senior Java developer persona with Effective Java principles, SOLID, and functional programming best practices.
Java Spring Boot 3 with JPA/Hibernate development guide following SOLID principles and OWASP best practices.
Expert guidance for building fast, scalable web apps with Astro, JavaScript, and Tailwind CSS.
