Update readme (thanks @mohammedalhaddar).

This commit is contained in:
Emil Stenström 2019-11-23 19:18:08 +01:00
parent 458b5383e0
commit f87f87dadf

View file

@ -3,11 +3,44 @@
A way to create simple reusable template components in Django.
# Installation
```pip install django-components``` (NOTE: Does not work yet)
Install the app into your environment:
> ```pip install git+https://github.com/EmilStenstrom/django-components.git#egg=django_components```
Then add the app into INSTALLED APPS in settings.py
```
INSTALLED_APPS = [
...,
"django_components",
...
]
```
## Optional
To avoid loading the app in each template using ``` {% load django_components %} ```, you can add the tag as a 'builtin' in settings.py
```
TEMPLATES = [
{
...,
'OPTIONS': {
'context_processors': [
...
],
'builtins': [
'django_components.templatetags.component_tags',
]
},
},
]
```
# Create your first component
A component in django-components is the combination of four things: CSS, Javascript, a Django template, and some Python code to put them all together.
A component in django-components is the combination of four things: CSS, Javascript, a Django template, and some Python code to put them all together.
First you need a CSS file. Be sure to prefix all rules with a unique class so they don't clash with other rules.