Jinja template to calculate the average

google-app-engine, jinja2, python

Solution

Jinja is a layout language, don't try to do code tasks in that language. It's great doing loops and conditionals, not great for doing arithmetic.

Calculate your average in the Python code and pass that value into your template.

Problem

I'm trying to display the average of numbers using jinja template but I couldn't make it up. I'm getting the value of 'points' column from the Google app engine datastore entity 'Score' Using python code and taking it in jinja template and I wanted to calculate the average of points and display through this template. ``` {% for num in number%} {{num.points}} {% endfor %} ```

Original source