This is my first post on StackOverflow so Hello everyone.
I'm doing blog application to learn Python and Flask and I would like to launch it on Google App Engine. Unfortunately I have small problem with importing WTForms to the application. I'm currently using Flask 0.9, WTForms 1.0.1 and Flask-WTForms 0.8. I've added flaskext_wtf folder to root path of my project but I'm getting error from 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 it tries to find wtforms inside the extension path instead of my project path. How can I inform the html5.py file to look for the wtforms in the root?
Here are sources of my project - https://bitbucket.org/lucas_mendelowski/wblog/src
I think your Virtualenv does not have the Flask-WTF module. Write the following command in your command line under virtualenv
pip install Flask-WTF
or you may do this, but it is not recommended.
easy_install Flask-WTF
I think, I finally manage with this issue (but I'm not sure if it's the right way).
Change imports in these files:
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
I've also posted a solution on github - https://github.com/rduplain/flask-wtf/issues/46#issuecomment-7376577
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With