wtforms

How FastAPI manages WFT Forms?

How FastAPI manages WFT Forms? Question: I am migrating from Flask to FastAPI and it is not clear to me how FastAPI manages WTF Forms. I would like to use forms in Classes. However, I don’t know if there is a correct way to do it in FastAPI, and if not what is the recommended …

Total answers: 2

Flask WTForms how to prevent duplicate form submission

Flask WTForms how to prevent duplicate form submission Question: I’m new to Flask. Forms.py: class NoteForm(FlaskForm): note = fields.TextAreaField("Note") add_note = fields.SubmitField("Add Note") router.py: add_note_form = forms.NoteForm() template: <div class="form-group"> {{ add_note_form.add_note}} </div> Now if I click the add note button multiple times in a very short time ,the form will be summitted for multiple …

Total answers: 1

How to configure __init__ in FlaskForm to have same functionalities?

How to configure __init__ in FlaskForm to have same functionalities? Question: So I want to pass a variable to a flask form, in order to do it I’ve decided to modify the __init__ of SongForm, but when I do it the album field loses its properties in the html. Does anyone know how do i …

Total answers: 1

Dynamically add new WTForms FieldList entries from user interface

Dynamically add new WTForms FieldList entries from user interface Question: I have a flask + wtforms app where I want users to be able to input both a parent object, and an arbitrary number of child objects. I’m not sure what the best way to dynamically create new child form input fields from the user …

Total answers: 3

Python Flask WTForms FloatField allow 1,0 and 1.0 allow comma and dot

Python Flask WTForms FloatField allow 1,0 and 1.0 allow comma and dot Question: I have a flask app where a user can submit a room. There is a price field which is a FloatField in my WTForms: preis = FloatField(‘Preis p.P.’, validators=[Optional()]) If the input is correct (with a dot) it works fine, example: 1.00 …

Total answers: 2

Testing a POST that uses Flask-WTF validate_on_submit

Testing a POST that uses Flask-WTF validate_on_submit Question: I am stumped on testing a POST to add a category to the database where I’ve used Flask_WTF for validation and CSRF protection. For the CRUD operations pm my website. I’ve used Flask, Flask_WTF and Flask-SQLAlchemy. It is my first independent project, and I find myself a …

Total answers: 3

Multi-part form using Flask / WTForms

Multi-part form using Flask / WTForms Question: I have a multi-part form to generate – think similar workflow to a Shopping Cart where you have multiple “sections” (eg details, billing, payment etc) for the one form that display one at a time. Key Details: I have 3 sections to the form The sections must be …

Total answers: 2

Clear valid form after it is submitted

Clear valid form after it is submitted Question: I want to reset the form after it validates. Currently the form will still show the previous data after it is submitted and valid. Basically, I want the form to go back to the original state with all fields clean. What is the correct to do this? …

Total answers: 4

Get an uploaded file from a WTForms field

Get an uploaded file from a WTForms field Question: In the Flask docs, the file upload example uses <input type=”file” name=”file”> then request.files[‘file’] to get the file. I’m using a WTForms FileField. How do I get the uploaded file when using WTForms rather than writing the input html myself? Asked By: Kevin Q || Source …

Total answers: 1

Add a * to required field's label

Add a * to required field's label Question: I want to add a ‘*’ before (or after) label’s text in case the filed is required. I can do this now by using this in my template: {% for field in form %} <label for=”{{ field.name }}”> {{ ‘*’ if field.flags.required }}{{ field.label.text }} : </label> …

Total answers: 3