I'm passing a dict from a Flask view to a Jinja template. I can render the values in the dict, but if I try to pass them to url_for
I get UndefinedError: 'dict object' has no attribute 'eId'
. Why did the second access fail when the first succeeded?
@app.route('/')
def show_entries():
if session.get('logged_in'):
cur = g.db.execute('select title, text, id from entries1 WHERE userid = ? OR public = 1 order by id desc', [userInfo['userid']])
else:
cur = g.db.execute('select title, text, id from entries1 WHERE public = 1 order by id desc')
entries = [dict(title=row[0], text=row[1], eId=row[2]) for row in cur.fetchall()]
return render_template('show_entries.html', entries=entries)
{% for entry in entries %}
This works: {{ entry.eId }}
This errors: {{ url_for('delete_entry', btnId=entry.eId) }}
{% endfor %}