0

I think I'm missing something extremely simple, but I'm trying to display the users name in my index.html, but i'm just getting blank

HTML/Jinja:

Welcome, <th>{{ user_data.username }} </th> Your current holdings are below.

Python:

user_data = db.execute("SELECT * FROM users WHERE id=:id", id=session["user_id"]) print(user_data) return render_template("index.html", user_data=user_data, data=data)

My jinja statements within my forloops work well, however.

1
  • When in doubt, try going one step back. Try: Welcome, <th>{{ user_data }} </th> and check the output. You may need to reference [user_data][username] for example.
    – PXSOCS
    Aug 14 '18 at 11:01
0

Remember, from the spec hints:

If str is a SELECT, then execute returns a list of zero or more dict objects, inside of which are keys and values representing a table’s fields and cells, respectively.

Even though the SQL will return exactly one row, user_data is still a list.

1
  • Ah, of course! Thank you.
    – Jake
    Aug 13 '18 at 21:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .