I have a dict with a list of values, basically each key has 10 values:
movies = {
'title': ['The Shawshank Redemption', 'The Godfather', ..., 'The Lord of the Rings: The Fellowship of the Ring'],
'year': ['1994', '1972', ..., '2001'],
'poster': ['url', 'url1', ..., 'url9'],
'rating': ['9.2', '9.1', ..., '8.8'],
'votes': ['2467733', '1705796', ..., '1732916']
}
I'm using them to dinamicaly generate cards in HTML so I need every card to have one value of each key. Ultimately I'll end up with 10 cards. Here's my HTML and my latest attempt to iterate the dict with jinja:
{% for movie in movies %}
{% for key, value in movie.items() %} <!-- This line is raising an error: jinja2.exceptions.UndefinedError: 'str object' has no attribute 'items' -->
{% for value in key %}
<div class="col-md-3">
<div class="card" style="width: 15rem;">
<img src="{{ value.poster }}" class="card-img-top" alt="Movie Poster">
<div class="card-body">
<h5 class="card-title">{{ value.title }}</h5>
<p class="card-text">Release year: {{ value.year }}</p>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">Rating: {{ value.rating }} - ({{ value.votes }} Votes)</li>
</ul>
<div class="card-body">
<a href="#" class="card-link">More</a>
</div>
</div>
</div>
{% endfor %}
{% endfor %}
{% endfor %}
What is the Jinja sintax to do it?