title: Python, Flask, and jinja templates - How to iterate over a dictionary created server side
body: <p>I am using flask.</p>
  
  <p>On the server server when a page loads I create a dictionary.</p>
  
  <pre><code>@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')
  </code></pre>
  
  <p>On the client side I want to iterate over the hash:</p>
  
  <pre><code>{% for crid, object in creative_handler.iteritems() %}
  
  {{ crid }}&lt;br&gt;
  
  {% endfor %}
  </code></pre>
  
  <p>On the page I get this error </p>
  
  <pre><code>UndefinedError: 'creative_handler' is undefined
  </code></pre>
  
  <p>So..how do I use jinja templates to iterate over a hash creates server side?</p>