Registry / web-framework / django-components

django-components

JSON →
library0.151.0pypypi✓ verified 85d ago

A library to create simple reusable template components in Django. Current version is 0.149.0, with active development and frequent releases (multiple per month). It supports Django 4.2+ and Python 3.10+. Key features include component slots, dynamic CSS/JS, and component nesting.

pip install django-components
INSTALL
IMPORT
SIG · DJANGO-COMPONENTS
D
django-components
web-frameworkpythonv0.151.0
Install
4.4s avg
Import
1177ms
Disk
98MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.151.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 1.228s · 98.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.4s · import 1.126s · 99MB
98MB installed
● package 98MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Component
from django_components import Component
from django_components.component import Component
Old import path (pre-v0.100) breaks; use top-level import.
render_to_response
from django_components import render_to_response
from django_components.library import render_to_response
Incorrect submodule path.

Define a simple component and render it in a Django template using the component_tags library.

from django_components import Component class Greeting(Component): template = """<div>Hello {{ name }}!</div>""" def get_context_data(self, name, **kwargs): return {"name": name} # Render in template: # {% load component_tags %} # {% component "greeting" name="World" / %}
django-components --version
Debug
Known issues
gotchaComponent templates are cached. If you modify a template file, you must restart the server or clear Django's template cache to see changes. Use a cache backend with auto-reload in development.
fix
Set django.template.backends.django.TEMPLATES loaders to cached.Loader only if you understand the caching; use FileSystemLoader for development.
affects: all
deprecatedComponent.Kwargs is now the preferred way to define input defaults instead of a separate Component.Defaults class. Component.Defaults still works but may be removed in the future.
fix
Migrate defaults to Kwargs: class Kwargs: show_details: bool = True
affects: >=0.143.0
breakingDropped support for Python 3.8 and 3.9, and Django 5.1 in version 0.147.0. Older releases may have security issues.
fix
Use Python 3.10+ and Django 4.2+ or 5.0+.
affects: >=0.147.0
gotchaGlobal JavaScript object renamed from `Components` to `DjangoComponents` in v0.146.0. Old object still available but deprecated.
fix
Update any JavaScript code referencing `window.Components` to `window.DjangoComponents`.
affects: >=0.146.0
Errors
Common errors & fixes
TemplateSyntaxError: 'django_components' is not a registered tag library
Forgetting to add 'django_components' to INSTALLED_APPS or not running migrate.
fix
Add 'django_components' to INSTALLED_APPS in settings.py and run python manage.py migrate.
KeyError: 'component_name'
Using the deprecated {% component_block %} syntax without registering the component.
fix
Register the component with @register('name') or use {% component 'name' / %} syntax after version 0.140.
ImportError: cannot import name 'Component' from 'django_components'
Outdated version or incorrect import path.
fix
Upgrade to latest: pip install -U django-components; use from django_components import Component.
Upgrade
Version history
0.151.0latest on PyPI · released Jun 3, 2026
Audit
Dependencies
DjangooptionalFramework requirement
Agent activity
6 hits · last 30 days
node
6
Resources
django-components — pip install django-components · libregistry