DEV Community

Cover image for Send python List of Dictionaries to jinja in a Flask Project
Areeb ur Rub
Areeb ur Rub

Posted on

Send python List of Dictionaries to jinja in a Flask Project

Sometimes it happens that the data is stored in two different tables but we want to run a for loop in Jinja which contains both the data from different databases.

So, sending two different lists won't work for us as the For-loop will then iterate the lists individually so in this case we have to send a list of dictionaries to jinja.


When I will use this

Suppose I am managing a class and I have two databases,
One has all the contact data like
name, address, Phone Number, etc.

And the Other one has data about how many times a particular student was absent.

The common column between two tables is the UID which is unique for every student

How it will be done

so, in that case, we can do this in Python: List of Dictionaries to jinja

And this on the (HTML)Jinja Side: List of Dictionaries to jinja

Top comments (0)