wtforms: dropdown selector with values defined in model class
<p>I would like to create a model for flask-wtforms where the values of the dropdown selectors are defined in the model already, as they are always the same. I tried the following:</p>

<pre><code>class DroppdownForm(Form):
    fields = {}
    df = pd.read_excel(open('formfile.xlsx', 'rb'), sheetname='Sheet1')

    df.fillna(value='NA', inplace=True)
    form_fields = ['COLUMN1', 'COLUMN2', 'COLUMN3']

    for form_field_name in form_fields:
        fields[form_field_name] = SelectField(form_field_name, sorted(df[form_field_name].unique().tolist()), description=form_field_name)
</code></pre>

<p>the view:</p>

<pre><code>def show_entries():
    form=DroppdownForm()
    return render_template('index.html', form=form)
</code></pre>

<p>When I then render it in the html file with</p>

<pre><code>{% macro render_field(field) %}
  &lt;dt&gt;{{ field.label }}
  &lt;dd&gt;{{ field(**kwargs)|safe }}
  {% if field.errors %}
    &lt;ul class=errors&gt;
    {% for error in field.errors %}
      &lt;li&gt;{{ error }}&lt;/li&gt;
    {% endfor %}
    &lt;/ul&gt;
  {% endif %}
  &lt;/dd&gt;
{% endmacro %}

 {% for field in form %}
     {{ render_field(field) }}
 {% endfor %}
</code></pre>

<p>The form is empty. What am I doing wrong?</p>