本文整理汇总了Python中wtforms.fields.StringField方法的典型用法代码示例。如果您正苦于以下问题:Python fields.StringField方法的具体用法?Python fields.StringField怎么用?Python fields.StringField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wtforms.fields
的用法示例。
在下文中一共展示了fields.StringField方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_form
# 需要导入模块: from wtforms import fields [as 别名]
# 或者: from wtforms.fields import StringField [as 别名]
def get_form(klass):
"""Gets the appropriate form for a given investigation"""
form = model_form(klass, exclude=klass.exclude_fields)
# An empty name is the same as no name
form.name = WTFStringField(
'Name', filters=[lambda name: name or None])
form.created_by = WTFHiddenField(
'created_by', default=current_user.username)
form.tags = TagListField("Tags")
return form
示例2: form
# 需要导入模块: from wtforms import fields [as 别名]
# 或者: from wtforms.fields import StringField [as 别名]
def form(self):
class TestLoginForm(Form):
username = StringField(u'Username', validators=[InputRequired()])
password = PasswordField(u'Password', validators=[InputRequired()])
submit = SubmitField(u'Log In using {}'.format(self.name))
return TestLoginForm
示例3: sqlalchemy_uri_form_validator
# 需要导入模块: from wtforms import fields [as 别名]
# 或者: from wtforms.fields import StringField [as 别名]
def sqlalchemy_uri_form_validator(_: _, field: StringField) -> None:
"""
Check if user has submitted a valid SQLAlchemy URI
"""
sqlalchemy_uri_validator(field.data, exception=ValidationError)
示例4: certificate_form_validator
# 需要导入模块: from wtforms import fields [as 别名]
# 或者: from wtforms.fields import StringField [as 别名]
def certificate_form_validator(_: _, field: StringField) -> None:
"""
Check if user has submitted a valid SSL certificate
"""
if field.data:
try:
utils.parse_ssl_cert(field.data)
except CertificateException as ex:
raise ValidationError(ex.message)