本文整理汇总了Python中wtforms.validators.Required方法的典型用法代码示例。如果您正苦于以下问题:Python validators.Required方法的具体用法?Python validators.Required怎么用?Python validators.Required使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wtforms.validators
的用法示例。
在下文中一共展示了validators.Required方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scaffold_form
# 需要导入模块: from wtforms import validators [as 别名]
# 或者: from wtforms.validators import Required [as 别名]
def scaffold_form(self):
"""
Sets up the review form to ensure that the rating field
behaves on a 1-5 scale.
"""
form_class = super(ReviewView, self).scaffold_form()
form_class.rating = IntegerField(
review_column_labels['rating'],
validators=[
validators.Required(),
validators.NumberRange(min=1, max=5)
]
)
form_class.staff_rating = IntegerField(
review_column_labels['staff_rating'],
validators=[
validators.Optional(),
validators.NumberRange(min=1, max=5)
]
)
form_class.intake_rating = IntegerField(
review_column_labels['intake_rating'],
validators=[
validators.Optional(),
validators.NumberRange(min=1, max=5)
]
)
return form_class
示例2: authenticate
# 需要导入模块: from wtforms import validators [as 别名]
# 或者: from wtforms.validators import Required [as 别名]
def authenticate():
"""Sends a 401 response that enables basic auth"""
return Response('Could not verify your access level for that URL.\n'
'You have to login with proper credentials', 401,
{'WWW-Authenticate': 'Basic realm="Login Required"'})