django-components


Namedjango-components JSON
Version 0.121 PyPI version JSON
download
home_pageNone
SummaryA way to create simple reusable template components in Django.
upload_time2024-12-17 19:38:43
maintainerNone
docs_urlNone
authorNone
requires_python<4.0,>=3.8
licenseMIT
keywords django components css js html
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # <img src="https://raw.githubusercontent.com/EmilStenstrom/django-components/master/logo/logo-black-on-white.svg" alt="django-components" style="max-width: 100%; background: white; color: black;">

[![PyPI - Version](https://img.shields.io/pypi/v/django-components)](https://pypi.org/project/django-components/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django-components)](https://pypi.org/project/django-components/) [![PyPI - License](https://img.shields.io/pypi/l/django-components)](https://github.com/EmilStenstrom/django-components/blob/master/LICENSE/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/django-components)](https://pypistats.org/packages/django-components) [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/EmilStenstrom/django-components/tests.yml)](https://github.com/EmilStenstrom/django-components/actions/workflows/tests.yml)

[**Docs (Work in progress)**](https://EmilStenstrom.github.io/django-components/latest/)

Django-components is a package that introduces component-based architecture to Django's server-side rendering. It aims to combine Django's templating system with the modularity seen in modern frontend frameworks.

## Features

1. 🧩 **Reusability:** Allows creation of self-contained, reusable UI elements.
2. 📦 **Encapsulation:** Each component can include its own HTML, CSS, and JavaScript.
3. 🚀 **Server-side rendering:** Components render on the server, improving initial load times and SEO.
4. 🐍 **Django integration:** Works within the Django ecosystem, using familiar concepts like template tags.
5. ⚡ **Asynchronous loading:** Components can render independently opening up for integration with JS frameworks like HTMX or AlpineJS.

Potential benefits:

- 🔄 Reduced code duplication
- 🛠️ Improved maintainability through modular design
- 🧠 Easier management of complex UIs
- 🤝 Enhanced collaboration between frontend and backend developers

Django-components can be particularly useful for larger Django projects that require a more structured approach to UI development, without necessitating a shift to a separate frontend framework.

## Quickstart

django-components lets you create reusable blocks of code needed to generate the front end code you need for a modern app. 

Define a component in `components/calendar/calendar.py` like this:
```python
@register("calendar")
class Calendar(Component):
    template_name = "template.html"

    def get_context_data(self, date):
        return {"date": date}
```

With this `template.html` file:

```htmldjango
<div class="calendar-component">Today's date is <span>{{ date }}</span></div>
```

Use the component like this:

```htmldjango
{% component "calendar" date="2024-11-06" %}{% endcomponent %}
```

And this is what gets rendered:

```html
<div class="calendar-component">Today's date is <span>2024-11-06</span></div>
```

Read on to learn about all the exciting details and configuration possibilities!

(If you instead prefer to jump right into the code, [check out the example project](https://github.com/EmilStenstrom/django-components/tree/master/sampleproject))

## Release notes

Read the [Release Notes](https://github.com/EmilStenstrom/django-components/tree/master/CHANGELOG.md)
to see the latest features and fixes.

## Community examples

One of our goals with `django-components` is to make it easy to share components between projects. If you have a set of components that you think would be useful to others, please open a pull request to add them to the list below.

- [django-htmx-components](https://github.com/iwanalabs/django-htmx-components): A set of components for use with [htmx](https://htmx.org/). Try out the [live demo](https://dhc.iwanalabs.com/).

## Contributing and development

Get involved or sponsor this project - [See here](https://emilstenstrom.github.io/django-components/dev/overview/contributing/)

Running django-components locally for development - [See here](https://emilstenstrom.github.io/django-components/dev/overview/development/)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "django-components",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "django, components, css, js, html",
    "author": null,
    "author_email": "Emil Stenstr\u00f6m <emil@emilstenstrom.se>",
    "download_url": "https://files.pythonhosted.org/packages/42/44/bdb4603403381ef6af6cb1578ce5f3190666f6c081c09613664334b3a031/django_components-0.121.tar.gz",
    "platform": null,
    "description": "# <img src=\"https://raw.githubusercontent.com/EmilStenstrom/django-components/master/logo/logo-black-on-white.svg\" alt=\"django-components\" style=\"max-width: 100%; background: white; color: black;\">\n\n[![PyPI - Version](https://img.shields.io/pypi/v/django-components)](https://pypi.org/project/django-components/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django-components)](https://pypi.org/project/django-components/) [![PyPI - License](https://img.shields.io/pypi/l/django-components)](https://github.com/EmilStenstrom/django-components/blob/master/LICENSE/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/django-components)](https://pypistats.org/packages/django-components) [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/EmilStenstrom/django-components/tests.yml)](https://github.com/EmilStenstrom/django-components/actions/workflows/tests.yml)\n\n[**Docs (Work in progress)**](https://EmilStenstrom.github.io/django-components/latest/)\n\nDjango-components is a package that introduces component-based architecture to Django's server-side rendering. It aims to combine Django's templating system with the modularity seen in modern frontend frameworks.\n\n## Features\n\n1. \ud83e\udde9 **Reusability:** Allows creation of self-contained, reusable UI elements.\n2. \ud83d\udce6 **Encapsulation:** Each component can include its own HTML, CSS, and JavaScript.\n3. \ud83d\ude80 **Server-side rendering:** Components render on the server, improving initial load times and SEO.\n4. \ud83d\udc0d **Django integration:** Works within the Django ecosystem, using familiar concepts like template tags.\n5. \u26a1 **Asynchronous loading:** Components can render independently opening up for integration with JS frameworks like HTMX or AlpineJS.\n\nPotential benefits:\n\n- \ud83d\udd04 Reduced code duplication\n- \ud83d\udee0\ufe0f Improved maintainability through modular design\n- \ud83e\udde0 Easier management of complex UIs\n- \ud83e\udd1d Enhanced collaboration between frontend and backend developers\n\nDjango-components can be particularly useful for larger Django projects that require a more structured approach to UI development, without necessitating a shift to a separate frontend framework.\n\n## Quickstart\n\ndjango-components lets you create reusable blocks of code needed to generate the front end code you need for a modern app. \n\nDefine a component in `components/calendar/calendar.py` like this:\n```python\n@register(\"calendar\")\nclass Calendar(Component):\n    template_name = \"template.html\"\n\n    def get_context_data(self, date):\n        return {\"date\": date}\n```\n\nWith this `template.html` file:\n\n```htmldjango\n<div class=\"calendar-component\">Today's date is <span>{{ date }}</span></div>\n```\n\nUse the component like this:\n\n```htmldjango\n{% component \"calendar\" date=\"2024-11-06\" %}{% endcomponent %}\n```\n\nAnd this is what gets rendered:\n\n```html\n<div class=\"calendar-component\">Today's date is <span>2024-11-06</span></div>\n```\n\nRead on to learn about all the exciting details and configuration possibilities!\n\n(If you instead prefer to jump right into the code, [check out the example project](https://github.com/EmilStenstrom/django-components/tree/master/sampleproject))\n\n## Release notes\n\nRead the [Release Notes](https://github.com/EmilStenstrom/django-components/tree/master/CHANGELOG.md)\nto see the latest features and fixes.\n\n## Community examples\n\nOne of our goals with `django-components` is to make it easy to share components between projects. If you have a set of components that you think would be useful to others, please open a pull request to add them to the list below.\n\n- [django-htmx-components](https://github.com/iwanalabs/django-htmx-components): A set of components for use with [htmx](https://htmx.org/). Try out the [live demo](https://dhc.iwanalabs.com/).\n\n## Contributing and development\n\nGet involved or sponsor this project - [See here](https://emilstenstrom.github.io/django-components/dev/overview/contributing/)\n\nRunning django-components locally for development - [See here](https://emilstenstrom.github.io/django-components/dev/overview/development/)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A way to create simple reusable template components in Django.",
    "version": "0.121",
    "project_urls": {
        "Homepage": "https://github.com/EmilStenstrom/django-components/"
    },
    "split_keywords": [
        "django",
        " components",
        " css",
        " js",
        " html"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f10122a2ef86c88a281b8914a4f5703b859f4ebb9eddeccde322e616513b08a3",
                "md5": "b7dec5ae16ec9f75119cf55dc06cb009",
                "sha256": "d5300ad77c40f4392faf5af96d370e5a863f3bc586b8213d4c68e6f6acf4b7c6"
            },
            "downloads": -1,
            "filename": "django_components-0.121-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b7dec5ae16ec9f75119cf55dc06cb009",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 103005,
            "upload_time": "2024-12-17T19:38:41",
            "upload_time_iso_8601": "2024-12-17T19:38:41.186931Z",
            "url": "https://files.pythonhosted.org/packages/f1/01/22a2ef86c88a281b8914a4f5703b859f4ebb9eddeccde322e616513b08a3/django_components-0.121-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4244bdb4603403381ef6af6cb1578ce5f3190666f6c081c09613664334b3a031",
                "md5": "623e7471f4cb317f96869d69aa28d7f7",
                "sha256": "e47b2175f4d3674bc0a384ddae983657fea99a1465bfc992a62189778eb694fe"
            },
            "downloads": -1,
            "filename": "django_components-0.121.tar.gz",
            "has_sig": false,
            "md5_digest": "623e7471f4cb317f96869d69aa28d7f7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 90858,
            "upload_time": "2024-12-17T19:38:43",
            "upload_time_iso_8601": "2024-12-17T19:38:43.622762Z",
            "url": "https://files.pythonhosted.org/packages/42/44/bdb4603403381ef6af6cb1578ce5f3190666f6c081c09613664334b3a031/django_components-0.121.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-17 19:38:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "EmilStenstrom",
    "github_project": "django-components",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "django-components"
}
        
Elapsed time: 0.45963s