1
I have this code in Flask (which uses the Jinja2)
{%block content%}
{% for i in posts %}
{% set x = x + 1 -%}
<p style="border: 1px solid black; padding: 5px 5px; border-radius: 5px;">{{ i[x] }}</p>
{% endfor %}
<form action="{{ url_for('redirectposts') }}">
<button class="btn btn-primary" type="submit">Posts</button>
</form>
{%endblock%}
- The x in this section starts as 0
return render_template('index.html', titulo="Home", posts=lista, x = 0)
'Posts' gets a list with some tuples.. The problem is that I can’t iterate the posts and put the tuples in the paragraphs (each tuple in a separate paragraph, going from the 1st to the last, as expected), instead it always returns a "p" like all tuples at once. How can I fix this?