Wiki
Clone wikiatl-hello-world-component / Home
atl-hello-world-component
This is a simple example of atl-django-component.
How to use it?
- Install atl-hello-world-component using pip
$ pip install atl-hello-world-component
- Add this app in
INSTALLED_APPS
inside settings.py
settings.py
... INSTALLED_APPS = ( ... 'sekizai', 'atl_django_component', 'atl_hello_world_component', ... ) ...
- Add in
context_processors
settings'sekizai.context_processors.sekizai'
Now you have 2 form of use the django-components (atl_hello_world
in this case):
###1. Create the component instance in the app view, put it in context and execute it in template page This is an example de instantiante a component in the view.
your_app_view.py
from atl_hello_world_component import HelloWorld ... def any_view(request): hello_world = HelloWorld() #Creating the instance hello_world.message = 'Hello people' # Applying some business logic context['hello_world'] = hello_world # Adding the instance in the context ...
your_app_template.html
{% load atl_django_component %}
... <!-- some html code -->
{% show_atl_component hello_world %}
...
###2. Instantiate and execute it in the template page
your_app_template.html
{% load atl_django_component %}
... <!-- some html code -->
{% create_and_show_atl_component 'atl_hello_world_component.HelloWorld' data_provider='Hello People' %}
...
Updated