Search code examples
python-3.xflaskjinja2flask-wtformsflask-restful

Render multiple dicts in muliple tabs for a flask application


I want to render multiple dicts json to front. All in the same interface. But each one in a specific tab. And the tabs have to be created dynamically based on the number of dicts. A basic example

[{"name" = a, "age" = 29},{"name" = b, "age" = 19}, {"name" = c, "age" = 28}]

The first tab will be a table containing the first dict {"name" = a, "age" = 29}, the second tab a table containing {"name" = b, "age" = 19} and so one. Knowing that I don't now the length of json in advance


Solution

  • The question is not very clear but from what I understood, you can do something like this:

    {% for tab in my_tab_list %}
    <tab> Name: {tab.name} Age: {tab.age} </tab>
    {% endfor %}