wtforms

sqlalchemy.exc.InterfaceError: <unprintable InterfaceError object>

让人想犯罪 __ 提交于 2019-12-02 04:04:41
问题 I'm trying out Flask but I'm having the error sqlalchemy.exc.InterfaceError: <unprintable InterfaceError object> while submitting a wtforms. The model class is: class Post(db.Model): __tablename__ = 'blog_posts' id = db.Column(db.Integer, unique=True, primary_key=True) title = db.Column(db.String(50), unique=False) content = db.Column(db.Text, unique=False) user_id = db.Column(db.String, db.ForeignKey('users.username')) @staticmethod def post_new_entry(title, content, user_id): """ Post new

Flask-WTF form has errors during GET request

耗尽温柔 提交于 2019-12-02 02:59:48
I have a Flask view with a Flask-WTF form. When I load the page in the browser, the form always has errors, even though I haven't submitted it yet. Why does the form have errors before it is submitted? @app.route('/', methods=['GET', 'POST']) def index(): form = ApplicationForm(request.form) if form.is_submitted(): print "Form successfully submitted" if form.validate(): print "valid" print(form.errors) if form.validate_on_submit(): return redirect('index') return render_template('index.html', form=form) 127.0.0.1 - - [30/Nov/2016 16:54:12] "GET / HTTP/1.1" 200 - {'department': [u'Not a valid

sqlalchemy.exc.InterfaceError: <unprintable InterfaceError object>

≡放荡痞女 提交于 2019-12-02 01:33:15
I'm trying out Flask but I'm having the error sqlalchemy.exc.InterfaceError: <unprintable InterfaceError object> while submitting a wtforms. The model class is: class Post(db.Model): __tablename__ = 'blog_posts' id = db.Column(db.Integer, unique=True, primary_key=True) title = db.Column(db.String(50), unique=False) content = db.Column(db.Text, unique=False) user_id = db.Column(db.String, db.ForeignKey('users.username')) @staticmethod def post_new_entry(title, content, user_id): """ Post new entry to database """ new_post = Post(title=title, content=content, user_id=user_id) db.session.add(new

Flask WTForms always give false on validate_on_submit()

独自空忆成欢 提交于 2019-12-02 01:15:33
I have created a signup form using wtforms. I am using FormField in it so that I don't have to repeat some of the elements of the form again. But whenever I click on the Submit button it always give me false on validate_on_submit method invocation. Not getting why is this happening. My form.py is as follows: class ProfileInfoForm(Form): firstname = TextField('firstname', validators= [validators.Required("Please enter First name.")]) lastname = TextField('lastname', validators= [validators.Required("Please enter Last name.")]) email = EmailField('email', validators= [validators.Required("Please

How to make Flask-WTFoms update labels dynamically from list of label names?

為{幸葍}努か 提交于 2019-12-01 23:21:10
I use WTForms to define form for data filtering it is defined like this (My goal is to have user specified labels for BooleanFields set, I let each user to name labels for fields and I save name of fields to Google Datastore): class MainFilterForm(FlaskForm): """ Represents main filter form. """ start_date = pendulum.parse( str(pendulum.today().year) + str(pendulum.today().month) + '01') end_date = pendulum.today() calendar_colors_descriptions = CalendarColorsDescription( users.get_current_user().user_id() ).get_colors_description() search_query = StringField( 'Search', [ validators.Length(min

How to make Flask-WTFoms update labels dynamically from list of label names?

◇◆丶佛笑我妖孽 提交于 2019-12-01 22:08:16
问题 I use WTForms to define form for data filtering it is defined like this (My goal is to have user specified labels for BooleanFields set, I let each user to name labels for fields and I save name of fields to Google Datastore): class MainFilterForm(FlaskForm): """ Represents main filter form. """ start_date = pendulum.parse( str(pendulum.today().year) + str(pendulum.today().month) + '01') end_date = pendulum.today() calendar_colors_descriptions = CalendarColorsDescription( users.get_current

WTForms error:TypeError: formdata should be a multidict-type wrapper

风流意气都作罢 提交于 2019-12-01 18:35:14
from wtforms import Form, BooleanField, TextField, validators,PasswordField class LoginForm(Form): username = TextField('Username', [validators.Length(min=4, max=25)]) password = PasswordField('Password') when i use LoginForm on webapp(gae) like this : def post(self): form=LoginForm(self.request) but it show error : Traceback (most recent call last): File "D:\Program Files\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 513, in __call__ handler.post(*groups) File "D:\zjm_code\forum_blog_gae\main.py", line 189, in post form=LoginForm(self.request) File "D:\zjm_code\forum

How to get a build a form with repeated elements well

烂漫一生 提交于 2019-12-01 17:50:17
The title really doesn't say it, as i'm having trouble summarizing the issue. So here goes the long explanation: Let's say I'm adding multiple contacts' information, and I have these fields: Name of the contact Method of Contact (email, phone number, instant message) If email: Show an email field (let's say this field exists) If phone number: Show a phone number field If instant message: Show a text field So right off the bat, I'm going to be needing JavaScript to complete this on the page itself (to add add or deletion contact fields), which I'm ok with. However, since I can add multiple

How to get a build a form with repeated elements well

别说谁变了你拦得住时间么 提交于 2019-12-01 17:05:15
问题 The title really doesn't say it, as i'm having trouble summarizing the issue. So here goes the long explanation: Let's say I'm adding multiple contacts' information, and I have these fields: Name of the contact Method of Contact (email, phone number, instant message) If email: Show an email field (let's say this field exists) If phone number: Show a phone number field If instant message: Show a text field So right off the bat, I'm going to be needing JavaScript to complete this on the page

Get data from WTForms form

隐身守侯 提交于 2019-12-01 08:43:09
How do I get the data from a WTForms form after submitting it? I want to get the email entered in the form. class ApplicationForm(Form): email = StringField() @app.route('/', methods=['GET', 'POST']) def index(): form = ApplicationForm() if form.validate_on_submit(): return redirect('index') return render_template('index.html', form=form) <form enctype="multipart/form-data" method="post"> {{ form.csrf_token }} {{ form.email }} <input type=submit> </form> Each field has a data attribute containing the processed data. the_email = form.email.data Working with form data is described in the getting