I am using flask.
On the server server when a page loads I create a dictionary.
@app.route('/edit_creative', methods=["GET", "POST"])
@login_required
def edit_creative():
if request.method == "POST":
pass
query = """select * from mystable"""
print query
rows = execute_query(query,select=True)
creative_handler={}
for row in rows:
j = row[2].strip("'")
j = json.loads(j)
creative_handler[row[1]]=j
return render_template("edit_creatives.html",title = 'Edit Creative')
On the client side I want to iterate over the hash:
{% for crid, object in creative_handler.iteritems() %}
{{ crid }}<br>
{% endfor %}
On the page I get this error
UndefinedError: 'creative_handler' is undefined
So..how do I use jinja templates to iterate over a hash creates server side?
You need to pass
creative_handlerto the template: