Skip to content
Advertisement

Tag: wtforms

MultiCheckbox Field Validation with Flask WTForms

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

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

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

Advertisement