I have a WTForm and I am trying to validate a custom multi-checkbox field, When I set the required flag to true, every checkbox needs to be checked. I just need at least one checkbox to be selected. When I don’t set the required flag, the native, and very elusive (is doesn’t appear in js, html, or css via developer
Tag: wtforms
Validation of WTForms in Flask using Postman
I am trying to Create a user using WTForms. But always I am getting validation error when checked using POSTMAN. I am not sure why this happens routes.py forms.py models.py Postman screen shot what can be the reason for validation always failing in this case. Thanks in advance Answer For this to work from POSTMAN, set the config
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
generating drop down list of users in database using wtforms and sqlalchemy
I am trying to generate a drop down list of all the users in my database so I can assign admins later that can edit their information. I keep getting the following error from my template: views.py forms.py models.py mobility_add_users.html More of the error readback I’m still new to this so please go easy on me. Answer Hope this helps.
has no attribute validate_on_submit: How to use wtforms-alchemy’s ModelForm in a flask handler / view
I’m trying to switch from wtforms.ext.sqlalchemy.orm import model_form to using wtforms_alchemy ModelForm: I’m failing miserably… and I’ve been unsuccessful searching for a working example of that uses wtforms_alchemy which shows both the handler and the model. Using model_form works for me: Here’s my working code using model forms: The model script (python): The handler script (python, flask, model_form): The template
WTForms-JSON not working with FormFields
Nested forms (FormFields) doesn’t get populated with data when I use WTForms-JSON. I can’t spot my mistake, see example below. I send the following JSON-request but the print after form.from_json(request.json) reveals that the address object is never populated with data (also, the “appropriate” errors are returned from the route). Print output: {‘name’: u’Alex’, ‘address’: {‘street’: u”, ‘number’: None}} I’m using
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