How to access the elements of a list of dictionaries sent by Flask in the html file

I am creating a web page using Flask and Bootstrap. The viewing function of the python code returns a list of dictionaries:

return render_template("home.html", data = dictionary_list)

Each item in the dictionary_list is a nested dictionary. It's structure is like this:

{
    "5W6M3": # This acts as the ID, and is different for each entry 
    {
      "Name": "John", 
      "Family Name": "Doe", 
      "Status": "Married", 
      "Age": 56, 
      "Office": ["NY", "London"]
    }
}

In the home.html file, I have this:

{% for entry in data %}
            <div class="card  mb-3">
              <div class="card-header">
              </div>
              <div class="card-body">
                <div class="row">
                  <div class="col">
                    <p><strong>ID: </strong>{{entry[???]}}</p>
                    <p><strong>Name: </strong>{{entry[???]}}</p>
                    <p><strong>Family Name: </strong>{{entry[???]}}</p>
                    <p><strong>Status: </strong>{{entry[???]}}</p>
                    <p><strong>Office: </strong>{{entry[???]}}</p>
                  </div>
                </div>
              </div>
            </div>
 {% endfor %}

How can I access the elements of each dictionary? In other words, what should I replace the ???s with?



Read more here: https://stackoverflow.com/questions/65056786/how-to-access-the-elements-of-a-list-of-dictionaries-sent-by-flask-in-the-html-f

Content Attribution

This content was originally published by gedoxeh676 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: