title: Validation of multiple radio buttons using Flask
body: <p>I have this python script that I use to send a list of dictionaries to a web page.</p>
  
  <pre><code>from flask import Flask, render_template
  from flask.ext.wtf import Form
  from wtforms.fields import RadioField
  
  app = Flask(__name__)
  app.config.from_object(__name__)
  
  class SimpleForm(Form):
      relevance = RadioField('Label', choices=[('0','A'), ('1','B'), ('2','C')])
  
  @app.route('/',methods=['post','get'])
  def hello_world():
      form = SimpleForm()
      if form.validate_on_submit():
          print form.relevance
      else:
          print form.errors
  
      stuff = {
              "text": "blah",
              "other": "random",
              "title": "21",
              "radios": form
          }
      stuff2 = {
              "text": "blah2",
              "other": "random2",
              "title": "22",
              "radios": form
          }
      all_stuff = {
          "mall": [stuff, stuff2]
      }
      return render_template('example.html', **all_stuff)
  
  if __name__ == '__main__':
      app.run(debug=True)
  </code></pre>
  
  <p>This is <code>example.html</code>:</p>
  
  <pre><code>&lt;form method="post"&gt;
      {% for a in mall %}
          {{ a.other }}&lt;br&gt;
          {{ a.title }}&lt;br&gt;
          {{ a.text }}&lt;br&gt;
          {{ a.radios.relevance }}&lt;br&gt;
      {% endfor %}
      &lt;input type="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This prints the two dictionaries but the Radio Buttons act like a single set of radio buttons. Here I have shown 2 dictionaries but I will be having like 50 dictionaries whose radio button values I have to submit. How can I do that? Whenever I submit I get <code>{'csrf_token': ['CSRF token missing']}</code></p>
  
  <p>Another thing is that why does this way of rendering Radio buttons result in a vertical list of radio buttons? Is there a way I can a get a horizontal representation of the buttons?</p>