I’m using Jinja2 on Google App Engine. I have a ListView which renders a generic template. At the moment, I’m not sure exactly what I want to display, so I just want to display each attribute of the model.
Is there a way to iterate over the object to output each one in a table cell?
For example:
{% for record in records %}
<tr>
{% for attribute in record %}
<td>{{ attribute }}</td>
{% endfor %}
</tr>
{% endfor %}
Any advice appreciated.
Thanks
This will do the trick in simple python code:
You can put the getattr function in the context so you can call it in jinja2 as shown below: