I am following CoreyMSchafer’s Flask-blog tutorial. Here, I can create, update and delete posts using WTForms and SQLAlchemy. However, to do that, I have to explicitly mention the name of the form fields. For example, to update a post (assuming a post only has title and content): where the model is and the WTForm is However, what if my form
Tag: flask-wtforms
What is the best way to create a dynamic selection list from database column with Python and Flask WFForms?
Spent several hours today trying to get the unique values in my database into a dropdown selection with Flask WTForms. The Database is MySQL, and I’m actually using SQLAlchemy for the majority of this app, but I’ve been unable to get unique values into the dropdown with SQLAlchemy (only seem to manage to get the string representaion in or the
How to call a variable outside a validate() function which is inside the FlaskForm class
I have two def validate(self) functions within the RegistrationForm(FlaskForm). First function validates the user input if the car range is over 400km. The other function validates if the user lives far or close to work by calculating the distance between the user’s address and work address by means of geopy module. I’ve been told that def validate_field(self, field): function takes
Deleting FlaskForm Fields depending on userinput in other forms
I have 3 forms with Checkboxes to configure the desired form (Final_Form). After the user chooses the desired fields (in form1, form2 and form3), i want to delet all fields that are not required in the final form and render the final form. The reason for that is, that i have 3 Subkategories with around 12 possible values, in each
How to handle file upload validations using Flask-Marshmallow?
I’m working with Flask-Marshmallow for validating request and response schemas in Flask app. I was able to do simple validations for request.form and request.args when there are simple fields like Int, Str, Float etc. I have a case where I need to upload a file using a form field – file_field. It should contain the file content. How can I
How can I create a form from a list of models using WTForms?
I have a list of Prediction models. I want to bind them to a form and allow the use to post back. How can I structure my form so the post associates a Home/Away score with a Prediction model’s id …