title: Set "selected" tag in responsive dropdown and select using Flask and jinja2
body: <p>I have a flask server which sends a dictionary of options to a dropdown or selection (in form).</p>
  <p>Here is the Python code:</p>
  <pre class="lang-py prettyprint-override"><code>@app.route(&quot;/&quot;, methods=['GET'])
  def index_get():
      options = {'o1' : 'option1', 'o2' : 'option2', 'o3' : 'option3'}
  
      return flask.render_template(&quot;index.html&quot;, options=options)
  </code></pre>
  <p>This is the Jinja code:</p>
  <pre><code>&lt;form method=&quot;post&quot;&gt;
      &lt;select name=&quot;test&quot;&gt;
          {% for id,name in options.items() %}
              &lt;option selected=&quot;&quot; value=&quot;{{ id }}&quot;&gt;{{name|safe}}&lt;/option&gt;
          {% endfor %}
      &lt;/select&gt;
  &lt;/from&gt;
  </code></pre>
  <p>Now, I want to set the <code>selected</code> attribute to one of the option, for example, <code>option2</code> from the Python code like <code>return flask.render_template(&quot;index.html&quot;, options=options, selected='option2')</code> or <code>selected='o2'</code>.<br />
  Can someone help me implementing this?</p>