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.11.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

django_viewcomponent-1.0.11-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_viewcomponent-1.0.11.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for django_viewcomponent-1.0.11.tar.gz
Algorithm Hash digest
SHA256 21c535af2fadde494f830e38fd4807ce6ccf12f2501f83c3f62a4b43288909f2
MD5 56ced5e4f2be1aadf08ce1357c282abe
BLAKE2b-256 838a596e501a193d1897b616e4e8481bf614c7b336718a520c03ed9782efb966

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_viewcomponent-1.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 aa4f1bf93ab2fc153a73ae9ad73ce85fd22fd3d225bd89f9274d10e1a03934d0
MD5 ac228e9613331c24bb1e1c0da61e5fa0
BLAKE2b-256 cb450d8830cdc9f097f1aa09fca21960b1b64e097d8f0275722af533aed96c62

See more details on using hashes here.

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