本文整理汇总了Python中forms.TestForm.append_field方法的典型用法代码示例。如果您正苦于以下问题:Python TestForm.append_field方法的具体用法?Python TestForm.append_field怎么用?Python TestForm.append_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.TestForm
的用法示例。
在下文中一共展示了TestForm.append_field方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BaseForm
# 需要导入模块: from forms import TestForm [as 别名]
# 或者: from forms.TestForm import append_field [as 别名]
import datetime
#######################
# define forms
class BaseForm(Form):
@classmethod
def append_field(cls, name, field):
setattr(cls, name, field)
return cls
from forms import TestForm
form = TestForm.append_field("do_you_want_fries_with_that",BooleanField('fries'))
form.append_field("do_you_want_a_burger_with_that",BooleanField('burger'))
class RegisterOwnerForm(Form):
name = StringField('Name', [validators.Required(), validators.Length(min=1,max=200,message='Please enter a name between 1 and 200 characters')])
class AdoptPuppyForm(Form):
pass
class NewPuppyForm(Form):
name = StringField('Name', [validators.Required(), validators.Length(min=1,max=200,message='Please enter a name between 1 and 200 characters')])
birth = DateField('Date of Birth (format mm/dd/yyyy)', [validators.Required(message='Please enter a date in format mm/dd/yyyy (including slashes)')], format='%m/%d/%Y')
gender = RadioField('Gender', choices=[('male','Male'),('female','Female')], default='female')
weight = DecimalField('Weight', [validators.Required(), validators.NumberRange(min=1.0, max=500.0,message="Please enter a value between 1.0 and 500.0")])
class DeletePuppyForm(Form):