Skip to main content

Build reusable components in Django, inspired by Rails ViewComponent

Project description

README

PyPI version PyPI Supported Python Versions

django-viewcomponent is a Django library that provides a way to create reusable components for your Django project.

It is inspired by Rails ViewComponent, which built by GitHub.com

For more insights into the problem it addresses and its design philosophy, check out this video by GitHub Staff member Joel Hawksley

Use Component in Django Template

You can create components and use them in Django templates.

Use Component in Django Template

Use Component in Python

Or you can create components and use them in pure Python code.

Use Component in Python

Why use django-viewcomponent

Single responsibility

django-viewcomponent can help developers to build reusable components from the Django templates, and make the templates more readable and maintainable.

Testing

django-viewcomponent components are Python objects, so they can be easily tested without touching Django view and Django urls.

Documentation

Documentation

FAQ

django-viewcomponent vs django-components

  1. django-viewcomponent is inspired by Rails ViewComponent, focusing solely on encapsulating Django templates without concerning itself with other elements such as frontend assets or generating Django responses.
  2. The slot field in django-viewcomponent can be invoked multiple times to pass collections.
  3. In django-viewcomponent, slot fields are declared in the Python component file rather than in the template file, making the slot field more flexible and easier to maintain.
  4. django-viewcomponent includes a preview feature that allows developers to easily create component previews.

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_viewcomponent-1.0.9.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

django_viewcomponent-1.0.9-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file django_viewcomponent-1.0.9.tar.gz.

File metadata

  • Download URL: django_viewcomponent-1.0.9.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for django_viewcomponent-1.0.9.tar.gz
Algorithm Hash digest
SHA256 6fc9e7478341c689a4750e8078fbd639eac6f91eebcdfc77a8c050ef1a5beeff
MD5 06f0116d8581beff0326c666a8ef809b
BLAKE2b-256 69400c13727e0b0a3ec00ff8f26d2f265fa45e9ed4b8bc7c822b9ff7aa88fb21

See more details on using hashes here.

File details

Details for the file django_viewcomponent-1.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for django_viewcomponent-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 859a0f3a27a41bb65ce0d08c7085d74a118ce15cf2215a3e792ba2b2fc07b25a
MD5 33eaceeb264b97a9d1d802ee2be0bc3b
BLAKE2b-256 64e5b889cf1e99bc4ea13d86830b6293459aa39bc2dce14fa929dd35e7ef8cb1

See more details on using hashes here.

Supported by

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