wtforms-json

wtforms SelectField with dynamic choices always returns “none” for data

穿精又带淫゛_ 提交于 2021-02-10 15:08:17
问题 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 import Form class SelectForm(Form): def __init__(self, csrf_enabled=False, *args, **kwargs): super(SelectForm, self).__init__(csrf_enabled=csrf_enabled, *args, **kwargs) fruits_list = wtforms.FieldList( wtforms.SelectField('fruits', validators =

wtforms SelectField with dynamic choices always returns “none” for data

爷,独闯天下 提交于 2021-02-10 15:02:21
问题 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 import Form class SelectForm(Form): def __init__(self, csrf_enabled=False, *args, **kwargs): super(SelectForm, self).__init__(csrf_enabled=csrf_enabled, *args, **kwargs) fruits_list = wtforms.FieldList( wtforms.SelectField('fruits', validators =

php, var_export fails with float [duplicate]

被刻印的时光 ゝ 提交于 2021-02-05 05:26:56
问题 This question already has answers here : Is floating point math broken? (31 answers) Closed 5 years ago . very simple. Consider this code: var_export (11.2); this returns with 11.199999999999999 with Php 5.6 wtf? 回答1: From the comments on the man page of php.net: Looks like since version 5.4.22 var_export uses the serialize_precision ini setting, rather than the precision one used for normal output of floating-point numbers. As a consequence since version 5.4.22 for example var_export(1.1)

php, var_export fails with float [duplicate]

≡放荡痞女 提交于 2021-02-05 05:25:45
问题 This question already has answers here : Is floating point math broken? (31 answers) Closed 5 years ago . very simple. Consider this code: var_export (11.2); this returns with 11.199999999999999 with Php 5.6 wtf? 回答1: From the comments on the man page of php.net: Looks like since version 5.4.22 var_export uses the serialize_precision ini setting, rather than the precision one used for normal output of floating-point numbers. As a consequence since version 5.4.22 for example var_export(1.1)

WTForms-JSON not working with FormFields

穿精又带淫゛_ 提交于 2019-12-22 08:34:49
问题 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, IntegerField from wtforms.validators import InputRequired import wtforms_json app = Flask(__name__) app.config["WTF_CSRF_ENABLED"] = False wtforms_json.init() class Address(Form): street = TextField('street', validators=[InputRequired()]) number =

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

爱⌒轻易说出口 提交于 2019-12-11 03:47:02
问题 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 app from .forms import PolicyForm import json import urllib2 @app.route('/policy', methods=['GET', 'POST']) def policy(): url = 'http://dcdemoappsrv1:8081/direct/policy?policyNumber=000000005&everything=true&discounts=true&coverages=true&vehicles

WTForms-JSON not working with FormFields

跟風遠走 提交于 2019-12-05 14:18:36
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, IntegerField from wtforms.validators import InputRequired import wtforms_json app = Flask(__name__) app.config["WTF_CSRF_ENABLED"] = False wtforms_json.init() class Address(Form): street = TextField('street', validators=[InputRequired()]) number = IntegerField('number', validators=[InputRequired()]) class User(Form): name = TextField('name', validators=