Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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.
Comment

PREVIOUS NEXT
Code Example
Python :: lucky number codechef solution 
Python :: binary list to decimal 
Python :: how to get more than one longest word in a list python 
Python :: dataframe python 
Python :: progress bar in python 
Python :: print data type array 
Python :: list out the groups from groupby 
Python :: python timestamp to string 
Python :: installing intel python 
Python :: edit path variable using python 
Python :: error: not well-formed (invalid token) 
Python :: how to use sin inverse and cos inverse in python 
Python :: moving element to last position in a list python 
Python :: find the place of element in list python 
Python :: teardown module pytest 
Python :: python array find lambda 
Python :: print all elements in list python 
Python :: pyqt5 drop down menu 
Python :: python machine learning 
Python :: pandas compare two columns of different dataframe 
Python :: django show image in admin page 
Python :: string concatenation in python 
Python :: download youtube video 
Python :: any function in python 
Python :: mongoengine 
Python :: python svg viewing 
Python :: python list object attributes 
Python :: PHP echo multiple lines example Using Nowdoc 
Python :: print on same line 
Python :: python day of the year 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =