Questions tagged [wtforms]
WTForms is a flexible forms validation and rendering library for Python.
1,463
questions
0
votes
2
answers
33
views
Flask Wtforms FieldList(FormField to populate a SelectField with choices is not appending to form
I am trying to populate a form using a combination of str and lists. The string fields in the form populate without issue. However the selectfield in the form appears to only display the last entry ...
0
votes
1
answer
17
views
Flask WTForm: Upon submission form is not validated
I am trying to implement a form that collects data on a concert venue and stores it on my local postgres database using wtforms and flask-sqlalchemy orm.
I have noticed that my form fails to validate ...
0
votes
0
answers
14
views
Is it possible to make a Flask WTForms TextAreaField horizontally expandable
Here's my code
class TestForm(FlaskForm):
textarea = TextAreaField("test", validators=[DataRequired()], widget=TextArea())
submit = SubmitField('submit')
<p>
{{ form....
0
votes
1
answer
20
views
Validating based on two different form data with WTF
I am trying to take two different input job,income and validate both before submit. Like if job is "Office" income must be in range of (55000,13000) it has 3 more condition like this. I have ...
0
votes
1
answer
28
views
wtform EqualTo does't validate
I'm trying to validate a form using EqualTo validator but even if I test with different inputs the form does't throw any error.
this is the code of route:
@app.route("/register", methods=[&...
-1
votes
1
answer
29
views
how does a flask server validates the form even after returning the html file itself?
@app.route("/register", methods=["GET", "POST"])
def register():
form = Form()
if form.validate_on_submit():
pass
return render_template("...
0
votes
0
answers
32
views
Why does my website flash "All Forms Required" and not fill the database even though I filled out all forms?
I have been having this problem where I submit a form and it gives me the error message all forms required. I already submitted the forms though. This is the error message.
Error Message. This is ...
0
votes
0
answers
22
views
Send Data from FlaskApi to WtForm(Similar to receiving response and Using it in Angular)
I'm new to Flask and WTForms. I was trying to create a calculator app, with only two input fields and return the Sum and display it below the same form. But I'm not sure on how to use the response ...
1
vote
1
answer
31
views
Set file limit when uploading multiple files flask wtforms
I was wondering how to set a validation method which limits the size of each file when using the flask wtform MultipleFileField before then being able to save the file.
There was a useful post here, ...
0
votes
2
answers
30
views
Flask-WTF not validating with FieldList subforms
I am trying to get a test form that includes subforms to work but the form does not validate on submission. The form itself is submitting a recipe with ingredients as its subforms using FieldList(). I ...
0
votes
1
answer
23
views
Creating hidden section in Flask, WTForms
I have a form using Flask and WTForms, the form has few required fields but a long list of optional fields. My problem is that I don’t want the page to be really long when the majority of users will ...
0
votes
1
answer
38
views
How to write data to .sqlite3 from SelectMultipleField (Flask), many to many relation, SQLAlchemy
I can add to database only title and content fields. But when it comes to adding categories from SelectMultipleField, it goes wrong. Now submit button of form (named 'Add') doesn't work when I select ...
0
votes
2
answers
32
views
Flask & WTForms: Execution Stops improperly on ValidationError
I'm using a WTForm with a custom validator the check for properly formatted phone numbers, care of the helpful package phonenumbers (https://pypi.org/project/phonenumbers/).
During testing, Form ...
0
votes
1
answer
45
views
How to fix "TypeError: 'UnboundField' object is not iterable"
class RegistrationForm(FlaskForm):
username = StringField('username', validators=[DataRequired(), Length(min=4, max=15)]
, render_kw={"placeholder": "...
0
votes
1
answer
33
views
wtforms import could not be resolved
I am trying to import wtforms, flask_wtf, and others into my flask app. All other solutions are saying to make sure it is installed in the right place. When I do "py -m pip show flask_wtf, py -m ...
0
votes
0
answers
20
views
Flask server crashes after form submit using js-npm-based form field (crbug/1173575 non-JS module files deprecated)
In my current project I try to implement a datepicker. So far it works, but as I want to submit the form with my custom datepicker, my application breaks and flask is turned off with just crbug/...
0
votes
1
answer
43
views
Flask-WTF form with a variable number of fields (a list of items)
I've a form to create a cocktail recipe. It has some common fields like name, description and others, and also a list of ingredients. An ingredient has an ID (foreign-key for a table of ingredients), ...
0
votes
0
answers
33
views
One to One Relationship in Flask WtForms
I've created a one-to-one for the group/role relationship in flask.
class Role(Base):
__tablename__ = "ab_role"
id = Column(Integer, primary_key=True)
name = Column(String(64), ...
0
votes
0
answers
17
views
can i change flask wtforms validators with variable
this is form
class VideoUploadForm(FlaskForm):
username = StringField('username', validators=[DataRequired()])
title = StringField('title', validators=[DataRequired()]) #equalTo("필드네임")
...
0
votes
1
answer
29
views
WTForms default values by current_user flask-login
I'm trying to make a few inputs have a default value retrieved from MongoDB, using mongoengine.
But when I'm trying to set a default value like this...
# Edit form (wtform)
class EditForm(FlaskForm):
...
0
votes
1
answer
54
views
How to customize Validation Error message in Flask-WTF [duplicate]
I have a custom validator in a Flask-WTF form that looks like this:
def is_some_condition_true(arg: str) -> bool:
return arg == "example"
def validation_func(self, arg: str) -> ...
0
votes
0
answers
15
views
Can WTForms be used for repersenting a page
I use flask WTforms to design forms for getting input from user. However, later I want to show some data in a page. Can I use WTForms for that purpose by populating it with data and changing the ...
0
votes
1
answer
67
views
Flask: Use multiple instances of one form
My website lets a teacher create multiple questions for an assignment. Once the assignment is created, a student can come and write an answer for each question.
My problem is that only one answer is ...
0
votes
1
answer
30
views
Flask-WTForm not submitting value
so after a user complained an error message, I discovered that my bank account field was not validating a length validator (WTForm). I disabled the length validator and implemented it myself. The ...
0
votes
1
answer
37
views
Dynamically Add or Remove WTForms validators in Flask
Is there a way to do this?
Below is an example of what I'm trying to do:
class TestForm(FlaskForm):
email = EmailField('Email', validators=[InputRequired('Email is required.')])
start = ...
0
votes
0
answers
10
views
WTForms skips validation when set to optional
This field is optional. WTForms does not validate according to a DecimalField if an entry has been made, but is not a decimal?
field = DecimalField("field", validators=[Optional()])
WTForms ...
0
votes
1
answer
27
views
Flask-WT Form: How to pass additional parameters for form
In a jinja template I want to have a class for the form:
{% macro build_form(form) %}
<form class="{{ form.form_class }}" role="form" method="post" action=""...
1
vote
0
answers
27
views
Flask WTForms, how to create a custom input with additional textinput
I want to override render for a DateField or TextField. I want to change it to a hidden input field and a text field. In text field I can pick a date in Persian calander but the corresponding ...
-1
votes
1
answer
51
views
How to fix "TypeError: object of type 'int' has no len()" on the line "if form.validate_on_submit():"?
Environment:
Python 3.7
I have a flask web form that fills a Mysql table.
I get this error :
TypeError: object of type 'int' has no len()
on the line:
if form.validate_on_submit():
of my routes.py
I ...
0
votes
0
answers
18
views
Flask and WTForms Post-Redirect-Get pattern causing CSRF error
I have an existing Flask application with an external database, and a view that provides users the ability to search one table based on user-defined criteria. Currently, the view renders the search ...
0
votes
0
answers
43
views
How can I grey out dates and times in the datefield and timefield in WTForms using FLASK
I am working on a booking system and I want the moments that are already booked to be unavailable to be picked again in the DateField and TimeField. I have the following form set up:
class ...
0
votes
0
answers
61
views
My code is not displaying a message I programmed it to show
It is a flask app that I am currently working on.
My code is supposed to validate user input. It is supposed to display a message whenever a user tries to create an account with an already existing ...
0
votes
1
answer
28
views
How to stop SqlAlchemy from generating SQL that inserts or updates the primary key?
I have a model:
class Contact(db.Model):
__tablename__ = 'contact'
contactid = db.Column(db.BigInteger, primary_key=True, server_default=db.text("nextval('contact_contactid_seq'::...
0
votes
0
answers
21
views
Create a list to use in SelectField in WTForms not working
New to this game, so please bear with me. I need to create a dropdown containing item name and brand name from a table/model I have created in my models.py file called 'Item'. The field comes up, but ...
2
votes
1
answer
72
views
How to handle error messages when validating a form across different FieldLists of FormFields?
I have a form that contains (among other fields) 2 FieldLists. Each FieldList is a list of FormFields. In each FieldList, the forms all represent projects. One fieldlist is for projects having ...
0
votes
0
answers
50
views
Can I target dropzone to a div instead of a form? If not can I easily overide the white background and border?
I followed this lesson from the docs and ran into an issue with the dropzone class. It styles the background white and makes the entire form area clickable/droppable. I tried to fix this with the ...
0
votes
1
answer
56
views
WTForms Validator NoneOf is not activating properly
I am trying to make a form that kicks back usernames with spaces and commas in WTForms. I tried using the NoneOf validator and it does not activate. Any suggestions? I named username to rusername for ...
0
votes
1
answer
36
views
FlaskForm not accepting field name 'process'
When I put the name of the field to 'process', Flask fails to process my form.
Here is the example code:
from flask import Flask, render_template_string
from flask_wtf import FlaskForm
from wtforms ...
0
votes
0
answers
22
views
Many to Many with extra field. How to print WTform
Story: Given User adds a new Measurement type, say "Arm", then User should be able to add value to "Arm" on each Customer.
Database Structure : "Customer" and "...
0
votes
2
answers
50
views
how to create 2 select fields with dependency in each other wtf_forms flask
class UpForm(FlaskForm):
"""Uploading form."""
user_file = FileField('please upload a file',validators=[FileRequired()])
category_1 = SelectField("main ...
0
votes
0
answers
27
views
WTForms, Jinja2, Flask - creating subform that is connected to another form
I'm creating a little project that's using MongoDB via flask server on Linux.
Now I'm stuck because I need retrieve data from forms in specific structure that corresponds with MongoDB database.
...
0
votes
1
answer
64
views
Use user's data as a value in SelectField for WTForms
I would like to use the user's data as a value in SelectField. I am trying to create a list of things the user has added to the database, then the user can see what they have added. So it should loop ...
0
votes
0
answers
48
views
how to set A4 page size for ckeditor
Recently I joined to the project. the project is being made using fastapi, blacksheep, and wtforms, There are some Text Areas using ckeditor 4. and my task is to make printable documents using ...
0
votes
0
answers
18
views
How to get user's input from mysql and use it as a placeholder for a SelectField in WTForms
I am trying to gather the users data and use their input as a placeholder for a SelectField in WTForms. I want it to show a list of the user's input and allow them edit their list.
I tried using the ...
-2
votes
1
answer
44
views
How to change Flask WTForm field value in HTML using javascript?
I have this simple hidden field in an HTML form:
<input type="hidden" id="response" name="response">{{ form.response}}</div>
and I want to change the it's ...
1
vote
1
answer
103
views
Process Data within Flask WTForms Submission
I would like to reformat the data submitted via WTForms by utilizing the process_data function. I am able to successfully submit the form, however, the data is not modified in the output as expected. ...
0
votes
1
answer
51
views
WTForms how to use description paramter
I have some simple boolean field and I want to add a short description.
I specified a description parameter but it seems like no effecr.
How it suppose to work at all?
from wtforms import BooleanField,...
0
votes
0
answers
28
views
Python wtforms disable validation by condition (allow to skip validation by special text or button)
I'm a novice in wtforms.
I created some fields with preferenced values enforced by validators. But in some cases, I want to ignore these validators.
Example: Admin gets a warning about inappropriate ...
0
votes
0
answers
46
views
How to change priority of WTForms validators?
tl;dr: I need to change the order in which WTForms validators validate the user input. How do I do that?
Details:
Flask code:
class SampleForm(Form):
user_email = user_email_field
...
@api.route('/...
1
vote
1
answer
47
views
How to get all checked items in SelectMultipleField in WTForms + Flask
I have a SelectMultipleField but when I try to access checked items, thought form.fields.data I only get the first of them.
More over, by trying to get answers directly from request.form.data through
...