Django-components

Latest version: v0.135

Safety actively analyzes 723158 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 9

0.135

Feat

- Add defaults for the component inputs with the `Component.Defaults` nested class. Defaults
are applied if the argument is not given, or if it set to `None`.

For lists, dictionaries, or other objects, wrap the value in `Default()` class to mark it as a factory
function:

python
from django_components import Default

class Table(Component):
class Defaults:
position = "left"
width = "200px"
options = Default(lambda: ["left", "right", "center"])

def get_context_data(self, position, width, options):
return {
"position": position,
"width": width,
"options": options,
}

`position` is used as given, `"right"`
`width` uses default because it's `None`
`options` uses default because it's missing
Table.render(
kwargs={
"position": "right",
"width": None,
}
)


- `{% html_attrs %}` now offers a Vue-like granular control over `class` and `style` HTML attributes,
where each class name or style property can be managed separately.

django
{% html_attrs
class="foo bar"
class={"baz": True, "foo": False}
class="extra"
%}


django
{% html_attrs
style="text-align: center; background-color: blue;"
style={"background-color": "green", "color": None, "width": False}
style="position: absolute; height: 12px;"
%}


Fix

- Fix compat with Windows when reading component files ([1074](https://github.com/django-components/django-components/issues/1074))
- Fix resolution of component media files edge case ([1073](https://github.com/django-components/django-components/issues/1073))

0.134

Fix

- HOTFIX: Fix the use of URLs in `Component.Media.js` and `Component.Media.css`

0.133

⚠️ Attention ⚠️ - Please update to v0.134 to fix bugs introduced in v0.132.

Fix

- HOTFIX: Fix the use of URLs in `Component.Media.js` and `Component.Media.css`

0.132

⚠️ Attention ⚠️ - Please update to v0.134 to fix bugs introduced in v0.132.

Feat

- Allow to use glob patterns as paths for additional JS / CSS in
`Component.Media.js` and `Component.Media.css`

py
class MyComponent(Component):
class Media:
js = ["*.js"]
css = ["*.css"]


Fix

- Fix installation for Python 3.13 on Windows.

0.131

Feat

- Support for extensions (plugins) for django-components!

- Hook into lifecycle events of django-components
- Pre-/post-process component inputs, outputs, and templates
- Add extra methods or attributes to Components
- Add custom extension-specific CLI commands
- Add custom extension-specific URL routes

Read more on [Extensions](https://django-components.github.io/django-components/0.131/concepts/advanced/extensions/).

- New CLI commands:
- `components list` - List all components
- `components create <name>` - Create a new component (supersedes `startcomponent`)
- `components upgrade` - Upgrade a component (supersedes `upgradecomponent`)
- `components ext list` - List all extensions
- `components ext run <extension> <command>` - Run a command added by an extension

- `djc_test` decorator for writing tests that involve Components.

- The decorator manages global state, ensuring that tests don't leak.
- If using `pytest`, the decorator allows you to parametrize Django or Components settings.
- The decorator also serves as a stand-in for Django's `override_settings`.

See the API reference for [`djc_test`](https://django-components.github.io/django-components/0.131/reference/testing_api/#djc_test) for more details.

- `ComponentRegistry` now has a `has()` method to check if a component is registered
without raising an error.

- Get all created `Component` classes with `all_components()`.

- Get all created `ComponentRegistry` instances with `all_registries()`.

Refactor

- The `startcomponent` and `upgradecomponent` commands are deprecated, and will be removed in v1.

Instead, use `components create <name>` and `components upgrade`.

Internal

- Settings are now loaded only once, and thus are considered immutable once loaded. Previously,
django-components would load settings from `settings.COMPONENTS` on each access. The new behavior
aligns with Django's settings.

0.130

Feat

- Access the HttpRequest object under `Component.request`.

To pass the request object to a component, either:
- Render a template or component with `RequestContext`,
- Or set the `request` kwarg to `Component.render()` or `Component.render_to_response()`.

Read more on [HttpRequest](https://django-components.github.io/django-components/0.130/concepts/fundamentals/http_request/).

- Access the context processors data under `Component.context_processors_data`.

Context processors data is available only when the component has access to the `request` object,
either by:
- Passing the request to `Component.render()` or `Component.render_to_response()`,
- Or by rendering a template or component with `RequestContext`,
- Or being nested in another component that has access to the request object.

The data from context processors is automatically available within the component's template.

Read more on [HttpRequest](https://django-components.github.io/django-components/0.130/concepts/fundamentals/http_request/).

Page 1 of 9

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.