Questions tagged [wtforms-json]

wtforms-json Adds smart json support for WTForms. Useful for when using WTForms with RESTful APIs.

wtforms-json Adds smart json support for WTForms. Useful for when using WTForms with RESTful APIs. WTForms-JSON is basically a WTForms extension for JSON data handling.

In order to use WTForms-JSON, you need to first initialize the extension. This monkey patches some classes and methods within WTForms and adds json handling support.

WTForm uses special flattened dict as a data parameter for forms. WTForms-JSON provides a method for converting JSON into this format.

14 questions
5
votes
1 answer

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. from flask import Flask, request, jsonify from flask_wtf import Form from wtforms import TextField, FormField,…
haeger
  • 623
  • 5
  • 14
5
votes
3 answers

WTForms-JSON with optional nesting using FormField

I'm using WTForms-JSON and processing nested forms. I'd like to make an inner form optional, but if the inner form is present, I'd like its fields to be required. The problem I'm running into is that FormField doesn't accept validators. (Although…
Jim Stewart
  • 16,964
  • 5
  • 69
  • 89
3
votes
2 answers

How to get wtforms to take json and insert data into the form object?

The situation: I am using React in the front-end and a Flask api server. I am wanting to send the data from React to the api and once I have done this I would like to use WTForms to run validations on the data before handling it. The question may…
Kwsswart
  • 529
  • 1
  • 7
  • 20
2
votes
1 answer

Why doesn't my WTForms-JSON form update correctly?

I am developing a web page that reads JSON and presents it in a form using WTForms-JSON. When I submit the form, form.data isn't updated. Why isn't this working? views.py: from flask import render_template, flash, redirect, request from app import…
1
vote
2 answers

Flask request.form contains data but request.data is empty and request.get_json() returns error

I am trying to create a data entry form "dynamically" (currently, I am using an array with 3 values, but in the future the number of elements in the array might vary) with nested dictionaries. This seems to work fine and the form is "properly"…
JSC
  • 21
  • 2
  • 7
1
vote
1 answer

WTForms, how to attach JSON data to the request

I'm bulding a form with WTForms for a Flask application. This form's las field is an address field that works with google PlacesAPI, so it autocompletes the address the user is introducing in that field. I want to be able to save all the data this…
Pedro Alejandro
  • 101
  • 1
  • 11
1
vote
1 answer

wtforms SelectField with dynamic choices always returns "none" for data

I am new to wtforms. I have to provide user with list of fruits and cost of each fruit as shown below, Total number of fruits are dynamically generated and each fruit prices is also dynamically generated. Below is my declaration, from flask.ext.wtf…
Sravan Kumar
  • 281
  • 1
  • 7
  • 18
0
votes
0 answers

Why I get this error in the json in the server?

I'm working on a project that involves connecting a client in C# with a server in C++. However, I'm encountering an error with the JSON that I pass from the client. Interestingly, I wrote a client in Python that works fine, so I'm struggling to…
Roni
  • 1
  • 1
0
votes
0 answers

how to set different id attributes for checkbox rendered via wtforms

I want to access the check boxes I rendered via wtforms in javascript and for that I want that each check boxes has a different id attribute, which for some reason I am not able to set. {% for task in allTodo %}

0
votes
2 answers

Trying to compare 3 wtforms fields with custom functions and geting recursion problem

I have 3 fields that I want to compare salary "from" field and "to" field and also there is fixed salary field. I have no idea how to do it, since there is no documentation how to do it, so i created custom function that look to each other and…
0
votes
1 answer

WTForms how to use description paramter

I have some simple boolean field and I want to add a short description. I specified a description parameter but it seems like no effecr. How it suppose to work at all? from wtforms import BooleanField, Form class AdminUsersForm(Form): foo =…
salius
  • 918
  • 1
  • 14
  • 30
0
votes
1 answer

"ModuleNotFoundError: No module named 'wtforms_json'" when installing Apache Superset

I am trying to install Apache Superset on EC2 but I get this error when I run this command: fabmanager create-admin --app superset ModuleNotFoundError: No module named 'wtforms_json' I am following the steps mentioned…
0
votes
0 answers

wtforms-json: How can I not allow None/empty string values?

I'm building a simple JSON API using Flask and wtforms-json. I have a problem where fields are allowed to be None, even when they really should not be, for example something this: wtforms.BooleanField('state', validators=[validators.Optional(),…
kshade
  • 21
  • 5
-1
votes
2 answers

Python - Write multiple JSON files each time user submits the form

This code writes a file named vip.json. Currently, it is overwriting the same file each time i submit the form. But, I want - Each time i click on submit in my form (which is built in flask) I want new files created for each submission. Something…
Bharath
  • 559
  • 11
  • 27