django-components
A way to create simple reusable template components in Django.
What it is and what it does
django-components is a UI framework that brings component-based architecture to Django templates. It lets you define reusable components as Python classes, each bundling its own HTML template, CSS styles, and JavaScript behavior into a single, self-contained unit. You register a component once and then use it anywhere in your templates via a simple tag syntax, passing data and slots just like in modern frontend frameworks.
The package extends Django's template system with Python expressions, literal data structures, spread operators, and slot-based composition, making it possible to build modular interfaces without leaving Django. Components can load their assets from files or define them inline, and they support dynamic data binding through get_template_data, get_js_data, and get_css_data methods. It's designed for projects of any size and is tested across major browsers.
Use it for:
- Build a reusable product card component that encapsulates display logic, styling, and interactivity in one place.
- Create a form component library where each field type (text input, dropdown, checkbox) is self-contained with its own validation and styling.
- Compose page layouts using slot-based components to share headers, sidebars, and footers across templates.
- Develop a design system where UI patterns (buttons, modals, tables) are versioned and shared across multiple Django projects.
- Reduce template duplication by extracting repeated HTML/CSS/JS patterns into registered components.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
django-components lets you build reusable, self-contained UI components in Django that bundle HTML, CSS, and JavaScript together, similar to Vue or React components but staying within the Django ecosystem.
Yes. django-components is actively maintained, has low install friction, carries a permissive MIT license, and solves a real problem—modular UI composition in Django—without requiring you to leave the Django ecosystem or adopt a separate frontend build system. It's suitable for both small and large projects and has no known security vulnerabilities.
Install
django-components on PyPI
pip
pip install django-componentsuv
uv add django-componentspoetry
poetry add django-componentsInstalling django-components
Before you install
Low friction install with a pure-Python wheel. Actively maintained with a release within the last 50 days. Depends on Django, djc-core, and typing-extensions—all standard, lightweight dependencies.
License in practice
MIT license is permissive; you can use, modify, and distribute this package with minimal restrictions in commercial or open-source projects.
Quickstart
pip install django-components
from django_components import Component, register
@register("my_component")
class MyComponent(Component):
template = "<div>{{ message }}</div>"
def get_template_data(self, args, kwargs, slots, context):
return {"message": kwargs.get("message", "Hello")}
# In template: {% component "my_component" message="World" %}
Requires Django 5.2 or 6.0 and Python 3.10 or later; must be installed in a Django project.
Verify before relying
- Performance characteristics when rendering many components or deeply nested component trees.
- Browser compatibility details beyond the stated testing across Chromium, Firefox, and WebKit.
- Whether djc-core is a separate package or an internal dependency, and what it provides.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — Django, djc-core, typing-extensions |
| Maintenance | actively maintained — 50 days since the last release |
| First released | |
| Downloads | 160,562/month — #10,655 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_components-0.151.1-py3-none-any.whl
Keywords: django, components, css, js, html
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
django-cottonDjango Cotton adds component-based UI…
permissive · top 15,000 on PyPI
vbuildCompiles Vue single-file components (*.vue) to…
permissive · top 15,000 on PyPI
django-classy-tagsProvides a class-based system for writing…
permissive · top 15,000 on PyPI
lacesLaces provides Django components that bundle…
permissive · top 5,000 on PyPI
django-webpack-loaderIntegrates Webpack-compiled bundles into Django…
permissive · top 5,000 on PyPI
django-compressorDjango Compressor combines, minifies, and…
permissive · top 5,000 on PyPI
django-pipelinedjango-pipeline bundles and compresses CSS and…
permissive · top 15,000 on PyPI
django-js-assetAdds script, stylesheet, and JSON tags with…
permissive · top 5,000 on PyPI
django-jinjaIntegrates Jinja2 templating into Django,…
permissive · top 15,000 on PyPI
djangocms-admin-styleProvides styled CSS templates and admin…
permissive · top 15,000 on PyPI