I’ve read the docs and looked at 2 different tutorials all do it the same way but my front end renders with empty tags but it creates a tag for the expect items in the database.
The desired behaviour is that there is a p tag for each row in the feedback column of the database.
I have a SQLite3 db, that has data in it, table created with this query:
CREATE TABLE feedback(id INTEGER PRIMARY KEY autoincrement,feedback TEXT NOT NULL);
This function gets all the data from the database
def listFeedback():
print("hello")
con = sql.connect("databaseFiles/database.db")
cur = con.cursor()
data = cur.execute('SELECT * FROM feedback').fetchall()
con.close()
return data
This renders the tempate
return render_template('/sucess.html', state=True, posts=listFeedback())
This is in the template
{% for post in posts %}
<div class='post'>
<p>{{ post['feedback'] }}</p>
</div>
{% endfor %}
If I have 6x items in the DB the front will have 6x empty p tags even though the feedback column has text content.
post.feedback has same effect but just using post will fill the P tag with all columns from each row when I just want the one row.
4
Try to use {{ post.feedback }}
Result will:
{% for post in posts %}
<div class='post'>
<p>{{ post.feedback }}</p>
</div>
{% endfor %}
ilias kazihodzhaev is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
4