Flask does not take WTForms input
<p>I'm tring to create an app with flask with WTForms.</p>

<p>In the controller.py i have:</p>

<pre><code>@mod_private.route('/portfolio/', methods=['GET', 'POST'])
@login_required
def portfolio():
   print "in portfolio"  # I read this
   form = CreateCoinsForm(request.form)
   if request.method == 'POST' and form.validate_on_submit():
       print form.coins.data   #I cannot take this value
       return render_template("private/portfolio.html",form=form)
   return render_template("private/portfolio.html",form=form)
</code></pre>

<p>in the forms.py:</p>

<pre><code>class CreateCoinsForm(Form):
    coins = IntegerField('coins', 
                        [DataRequired('num required'),
                         NumberRange(min=0, max=10)])
</code></pre>

<p>and the template</p>

<pre><code>&lt;form method="post" action="/private/portfolio/" accept-charset="UTF-8" role="form"&gt;
           &lt;p&gt; {{ form.coins }}&lt;/p&gt;
        &lt;p&gt;&lt;input type=submit value=Generate&gt;
    &lt;/form&gt;
</code></pre>

<p>my problem, as i wrote in the code is that I cannot retrieve the string inserted in the template.</p>

<p>Your problem suggests that you are using the built-in CSRF protection on your form, and your form actually isn't validating because you haven't included the CSRF token. </p>

<p>Try adjusting your template like so:</p>

<pre><code>&lt;form method="post" action="/private/portfolio/" accept-charset="UTF-8" role="form"&gt;
   {{ form.hidden_tag() }}
           &lt;p&gt; {{ form.coins }}&lt;/p&gt;
        &lt;p&gt;&lt;input type=submit value=Generate&gt;
    &lt;/form&gt;
</code></pre>

python flask wtforms