Counter in JINJA2

You can set a counter in a for loop using:

{% set vars={'value': 0} %}

{% for month in range(0,12) %}
        {% if vars.update({'value': vars['value'] + 1 }) %}{% endif %}
{% endfor %}
more ...

Embebed graphs using pygal

If we want the graph just as an svg (you wont be able to print it) you have to add this code to de controller:

chart = bar_chart.render(is_unicode=True)

and in the template:

{{ chart|safe }}

But if you want to generate a PNG on the fly:

chart = b64encode(bar_chart ...
more ...

Flask - Migrate

The Flask-Migrate plugin allows using an shell interface for Alembic

With Alembic you can manage changes in the database model providing a version control tool and easing the recreation of the database on any design change

First steps

On the project setup we execute

$ python manage.py db init

Or ...

more ...