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
You can create components and use them in Django templates.
Or you can create components and use them in pure Python code.
django-viewcomponent can help developers to build reusable components from the Django templates, and make the templates more readable and maintainable.
django-viewcomponent components are Python objects, so they can be easily tested without touching Django view and Django urls.
- 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.
- The
slot
field in django-viewcomponent can be invoked multiple times to pass collections. - 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.
- django-viewcomponent includes a preview feature that allows developers to easily create component previews.