Answers for "loop through list of lists jinja"

0

loop through list of lists jinja

#Data:
parent_list = [{'A': 'val1', 'B': 'val2'}, {'C': 'val3', 'D': 'val4'}]

#in Jinja2 iteration:

{% for dict_item in parent_list %}
   {% for key, value in dict_item.items() %}
      <h1>Key: {{key}}</h1>
      <h2>Value: {{value}}</h2>
   {% endfor %}
{% endfor %}

# Note:
# Make sure you have the list of dict items. If you get UnicodeError may be the value inside the dict contains unicode format. That issue can be solved in your views.py. If the dict is unicode object, you have to encode into utf-8.
Posted by: Guest on March-03-2022

Code answers related to "loop through list of lists jinja"

Python Answers by Framework

Browse Popular Code Answers by Language