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
ModuleNotFoundError: No module named ‘wtforms.fields.html5’
I have a flask app that uses wtforms. I have a file which does: I just wanted to rebuild my docker container and now I have this error: I have in my requirements.txt: I tried to add flask_WTF but it did not fix it. Any idea what’s going on? I thought of upgrading wtforms but it seems like I have
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
Using uk-postcode-utils in a python form
I am creating a form for the user to enter a valid UK postcode. I currently have the following code for the form: and the template is: but getting the error: TypeError: argument of type ‘StringField’ is not iterable. What can I do to fix this? Edit: Here are the complete form entry and the template for the webpage. Thanks
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 field for each item I bind to the form? view form template I am unable to get my data to
I’m not able to import Flask-WTF TextField and BooleanField
I’m using virtualenv to set up a new project. I installed a lot of things using virtualenv pip from the script folder like below: I have no other packages installed in the global python folder. My code looks like this: and other packages are found like sqlalchemy also installed only in the virtual environment. The error I get is: Form