当前位置: 首页>>代码示例>>Python>>正文


Python TestForm.append_field方法代码示例

本文整理汇总了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):
开发者ID:philnova,项目名称:puppyadopter,代码行数:33,代码来源:views_wtf.py


注:本文中的forms.TestForm.append_field方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。