Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing flask.ext.wtf

I am using venv, and I develop using eclipse . I want to add a contact page .

I did :

$ . bin/activate
$ pip install flask-wtf

And I import some modules in the forms.py :

I used this :

from flask.ext.wtf import Form, TextField, TextAreaField, SubmitField

and then this :

from flask.ext.wtf import Form
from wtforms.fields import TextField, BooleanField

No one of them worked because I had this error :

from flask.ext.wtf import Form
  File "/usr/local/lib/python2.7/dist-packages/flask/exthook.py", line 87, in load_module
    raise ImportError('No module named %s' % fullname)
ImportError: No module named flask.ext.wtf
like image 823
4m1nh4j1 Avatar asked Dec 13 '13 15:12

4m1nh4j1


2 Answers

I had to use

from flask_wtf import Form

instead of

from flask.ext.wtf import Form
like image 53
Darek Deoniziak Avatar answered Nov 02 '22 07:11

Darek Deoniziak


What version of flask-wtf did you install? Since version 9 you do all of the field imports from WTForms not from Flask-WTF.

So your imports will be (note that according to docs import statement was changed):

from flask_wtf import Form
from wtforms import TextField, BooleanField
like image 23
Ptrkcon Avatar answered Nov 02 '22 07:11

Ptrkcon