django-cotton
Enabling Modern UI Composition in Django.
Decision gist · record as of 2026-08-14
Yes. Django Cotton is actively maintained, has no known vulnerabilities, installs with minimal friction, and solves a real pain point in Django template composition. It's marked Production/Stable and sits in the top 15000 packages by download volume. Install it if you want component-based UI design without leaving Django's template system.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction install as a pure Python wheel with only django as a runtime dependency.
- Marked as Production/Stable with active maintenance; last release 74 days ago.
License · maintenance · safety
MIT (permissive) — MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal obligations.
last release 2026-06-01 (74 days)
0 known vulnerabilities (OSV.dev, 2026-08-14) · 419,317 downloads/mo, #6,800 on PyPI
Alternatives
Verify before relying
pip install django-cotton
# In settings.py
INSTALLED_APPS = [
'django_cotton'
]
# In templates/cotton/button.html
{{ slot }}
# In your template
<c-button url="/contact">Contact</c-button>- Whether the package works with all listed Python versions (3.8–3.14) in practice or if some are aspirational
- Performance impact of component compilation and caching on template rendering at scale
- Compatibility with Django versions beyond the classifier hints
What it is and what it does
Django Cotton extends Django's template language to support component-based UI design. Instead of writing template fragments scattered across files, you define reusable components in a templates/cotton folder and invoke them with HTML-like syntax (<c-my-component />). Components support slots for content injection, named slots for multi-region layouts, attributes both static and dynamic, boolean flags, and Python data types. The package compiles components to native Django template tags at load time with built-in caching and automatic invalidation on file changes.
It solves the friction of composing modular UIs in Django without requiring a separate templating engine. Components encapsulate layout, styling, and interaction logic in one file, work well alongside Tailwind and Alpine.js, and integrate with HTMX for dynamic behavior. The syntax is HTML-native, so code editors provide highlighting, formatting, and autoclosing out of the box.
Use it for
- Build a reusable button component with icon slots and URL attributes to avoid duplicating button markup across templates.
- Create form input components that accept arbitrary HTML attributes via the {{ attrs }} variable to reduce boilerplate.
- Compose a bio-card component that accepts context variables (:user="user") to render profiles without template duplication.
- Define HTMX-enabled components that can be rendered directly from views and reused across multiple pages.
- Organize complex layouts by nesting components with named slots to separate concerns between parent and child templates.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Django Cotton is actively maintained, has no known vulnerabilities, installs with minimal friction, and solves a real pain point in Django template composition. It's marked Production/Stable and sits in the top 15000 packages by download volume. Install it if you want component-based UI design without leaving Django's template system.
Install
django-cotton on PyPI
Before you install
Low friction install as a pure Python wheel with only django as a runtime dependency. Marked as Production/Stable with active maintenance; last release 74 days ago.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal obligations.
Quickstart
pip install django-cotton
# In settings.py
INSTALLED_APPS = [
'django_cotton'
]
# In templates/cotton/button.html
{{ slot }}
# In your template
<c-button url="/contact">Contact</c-button>
Verify before relying
- Whether the package works with all listed Python versions (3.8–3.14) in practice or if some are aspirational
- Performance impact of component compilation and caching on template rendering at scale
- Compatibility with Django versions beyond the classifier hints
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release <4,>=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagedjango |
| Maintenance | Actively maintained 74 days since the last release |
| First released | |
| Downloads | 419,317 / month, #6,800 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableFramework :: DjangoIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9 |
Evidence: django_cotton-2.7.2-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “component-based templates”
- django-cottonDjango Cotton adds component-based UI composition to Django…
- solara-serverSolara-server is a Python web framework that runs React-style…
- django-componentsdjango-components lets you build reusable, self-contained UI…
Give your agent the search over MCP, or paste the wish link into any chat.
More Dynamic Content packages
MarkupSafe provides a text object that escapes special characters so untrusted strings can be safely embedded in HTML and XML without injection attacks.
Jinja2 is a templating engine that renders dynamic content by combining templates with Python-like syntax and data, supporting template inheritance, macros, autoescaping, and sandboxed execution.
Soupsieve is a CSS selector library designed to work with Beautiful Soup 4 to select, match, and filter HTML and XML elements using modern CSS selectors from CSS level 1 through CSS level 4 specifications.
Install it if you use Beautiful Soup for HTML or XML parsing and want modern CSS selector support.
Werkzeug is a WSGI utility library providing request/response objects, URL routing, an interactive debugger, HTTP utilities, and a development server for building web applications.
Flask is a lightweight WSGI web application framework for building web applications in Python, from simple single-page sites to complex multi-route applications.
Mako compiles Python-embedded templates into Python modules for fast rendering, supporting layout inheritance, custom functions, and direct Python expressions within template syntax.
See also django-components · laces · ipyvuetify · django-admin-extra-buttons · trame-vuetify · reflex-components-code · django-braces · django-jinja · django-template-partials · django-htmx