Flask-WTForms cannot find WTForms in my project directory

This is my first StackOverflow post, so hello everyone.

I am doing a block application to learn Python and Flask, and I would like to run it in the Google App Engine. Unfortunately, I have a little problem importing WTForms into the application. I am currently using Flask 0.9, WTForms 1.0.1 and Flask-WTForms 0.8. I added the flaskext_wtf folder to the root path of my project, but I get an error message from the html5.py file.

File "/Users/lucas/Workspace/blog/flask_wtf/html5.py", line 1, in <module>
from wtforms import TextField
File "/Users/lucas/Workspace/blog/flask/exthook.py", line 86, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named flask.ext.wtf.wtforms

It looks like he is trying to find wtforms inside the extension path instead of my project path. How can I tell the html5.py file to search for wtforms in the root?

Here are the sources of my project - https://bitbucket.org/lucas_mendelowski/wblog/src

+5
4

, Virtualenv Flask-WTF. virtualenv

pip install Flask-WTF

, .

easy_install Flask-WTF
+2

, ( , ).

:

1) flaskwtf/init_.py

From:

from flask.ext.wtf import html5
from flask.ext.wtf.form import Form
from flask.ext.wtf import recaptcha

from flask.ext.wtf.recaptcha.fields import RecaptchaField
from flask.ext.wtf.recaptcha.widgets import RecaptchaWidget
from flask.ext.wtf.recaptcha.validators import Recaptcha

To:

import html5
from form import Form
import recaptcha

from recaptcha.fields import RecaptchaField
from recaptcha.widgets import RecaptchaWidget
from recaptcha.validators import Recaptcha

2) flaskwtf/recaptcha/init_.py:

From:

from flask.ext.wtf.recaptcha import fields
from flask.ext.wtf.recaptcha import  validators 
from flask.ext.wtf.recaptcha import  widgets

To:

import fields
import validators 
import widgets

github - https://github.com/rduplain/flask-wtf/issues/46#issuecomment-7376577

+1

. , , :

from flask.ext.wtf import wtforms

. :

from flask.ext.wtf import Form, TextField

HTML5, . , URLField

from flask.ext.wtf.html5 import URLField
0

. , , Flask-WTF, WTForm.

, .

From version 0.9.0, Flask-WTF will not import anything from wtforms 
you need to import fields from wtforms.


    from flask_wtf import Form
    from wtforms import TextField
    from wtforms.validators import DataRequired

    class MyForm(Form):
        name = TextField('name', validators=[DataRequired()])

Flask-WTF.

0
source

All Articles