title: How to POST data to Flask from Bootstrap List-Group
body: <p>I am creating a polling web application written in Python, HTML, CSS/Bootstrap, Flask. I have created the answer page where a user can select an option of the question, it is highlighted in blue, once the user presses submit it should POST the data so that I can write it to the database.</p>
  <p>When I read the request form for POST it shows a blank dictionary.</p>
  <p>I want it to function like this (this works as intended):</p>
  <pre><code>&lt;form method=&quot;POST&quot;&gt;
      &lt;h3 style=&quot;text-align: center&quot;&gt;{{question}}&lt;/h3&gt;
      &lt;div&gt;
          {% for row in data %}
          &lt;input type=&quot;checkbox&quot; id={{ row[&quot;choice&quot;] }} name={{ row[&quot;choice&quot;] }} value={{ row['text'] }}&gt;
          &lt;label for={{ row['choice'] }}&gt;{{ row['text'] }}&lt;/label&gt;&lt;br&gt;
          {% endfor %}
      &lt;/div&gt;
  &lt;br/&gt;
  &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary pull-right&quot;&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  
  </code></pre>
  <p>But have a frontend style like this:</p>
  <pre><code>&lt;form method=&quot;POST&quot;&gt;
      &lt;h3 style=&quot;text-align: center&quot;&gt;{{question}}&lt;/h3&gt;
      &lt;div&gt;
          &lt;div class=&quot;col&quot;&gt;
              &lt;div class=&quot;list-group&quot; id=&quot;list-tab&quot; role=&quot;tablist&quot;&gt;
                  {% for row in data %}
                      &lt;button type=&quot;button&quot; class=&quot;list-group-item list-group-item-action&quot; id={{ row['choice'] }} data-toggle=&quot;list&quot;&gt;{{ row['text'] }}&lt;/button&gt;
                  {% endfor %}
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;br/&gt;
  &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary pull-right&quot;&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  <p>I want to grab the selected choice from the user:</p>
  <pre><code>@routes.route('/answer_poll', methods=['GET', 'POST'])
  def answer_poll():
      if request.method == &quot;POST&quot;:
          form = request.form
  
          # SHOW USER'S ANSWER
          for key in form.keys():
              for value in form.getlist(key):
                  print(key+&quot; : &quot;+value)
          
          flash(&quot;Response Recorded&quot;, category=&quot;success&quot;)
          return redirect(url_for('routes.results'))
  
  # GET METHOD ...
  </code></pre>