From f87f87dadfd8f80c7263a8a98b456571d43356ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Stenstr=C3=B6m?= Date: Sat, 23 Nov 2019 19:18:08 +0100 Subject: [PATCH] Update readme (thanks @mohammedalhaddar). --- README.md | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 90848a71..aa30dca3 100644 --- a/README.md +++ b/README.md @@ -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.