Skip to main content

Lightweight reusable template components for Django. An exploratory fork of django-components.

Project description

django-components-lite

An exploratory, lightweight fork of django-components.

This package strips django-components down to its core: simple, reusable template components for Django, just templates with some optional python logic. The goal is to see how a minimal django-components feels in practice.

Attribution

This project is built on the excellent work of the django-components project by Emil Stenström, Juro Oravec, and all contributors. Their years of work made this possible.

If you're looking for a mature, full-featured, and battle-tested component library for Django, use django-components. It has an active community, extensive documentation, and a rich feature set.

Features

What django-components-lite keeps from django-components:

  • Component classes with Python logic and Django templates
  • {% comp %} / {% endcomp %} template tags
  • Slots and fills ({% slot %}, {% fill %})
  • Component autodiscovery
  • Component registry
  • Static file handling (JS/CSS)
  • Isolated component context
  • HTML attribute rendering utilities

What's removed?

Compared to django-components, the following have been stripped out:

  • Extension system
  • Built-in components (DynamicComponent, ErrorFallback)
  • Component caching
  • Provide/Inject system
  • Template expressions
  • Management commands
  • JS/CSS data methods and dependency management
  • Type validation (Args/Kwargs/Slots/TemplateData)
  • on_render() generator system and deferred rendering
  • context_behavior setting (always isolated, like Django's inclusion_tag)
  • Tag formatters
  • Component views and URLs
  • libraries setting and import_libraries()
  • reload_on_file_change setting
  • All deprecated setting aliases

Installation

pip install django-components-lite

Add to your Django settings:

INSTALLED_APPS = [
    # ...
    "django_components_lite",
]

Quick example

# myapp/components/greeting/greeting.py
from django_components_lite import Component, register

@register("greeting")
class Greeting(Component):
    template_file = "greeting.html"

    def get_context_data(self, name):
        return {"name": name}
<!-- myapp/components/greeting/greeting.html -->
<div class="greeting">
  Hello, {{ name }}!
  {% slot "extra" %}{% endslot %}
</div>
<!-- In any template -->
{% load component_tags %}
{% comp "greeting" name="World" %}
  {% fill "extra" %}
    <p>Welcome!</p>
  {% endfill %}
{% endcomp %}

Links

License

MIT - see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_components_lite-0.5.1.tar.gz (69.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_components_lite-0.5.1-py3-none-any.whl (45.6 kB view details)

Uploaded Python 3

File details

Details for the file django_components_lite-0.5.1.tar.gz.

File metadata

  • Download URL: django_components_lite-0.5.1.tar.gz
  • Upload date:
  • Size: 69.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_components_lite-0.5.1.tar.gz
Algorithm Hash digest
SHA256 6618b51b686ac7d35e3db504284abb2b095e0174ffe937b7f4984a772c27d256
MD5 50af8e98f060c1011dd08c98f6caf707
BLAKE2b-256 1ad2f324428d579fb9f78b5ef6d993ade196e6a0f4368a51d930db4d64b15eff

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_components_lite-0.5.1.tar.gz:

Publisher: publish.yml on oliverhaas/django-components-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_components_lite-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_components_lite-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 be348767570bd2b508292b06f57a2a3bc3d5b4343ff721ddacb20cd4778369ef
MD5 190dfd989324d0dcbc6fe8b0a5b7ad5b
BLAKE2b-256 a850c783c66195a7f4249638b111e3c4dcc1139e56c94fcd12e7eca1dcac02ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_components_lite-0.5.1-py3-none-any.whl:

Publisher: publish.yml on oliverhaas/django-components-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page