代码和文档见 https://github.com/robertzhai/python/tree/master/flask_coupon
1. wtf 文档
http://docs.jinkan.org/docs/flask-wtf/
2.使用 方法如下
class CouponForm(Form):
pid = StringField(
'pid',
validators=[ DataRequired(), Regexp(
r'^\d+$',
message=
'pid param error')])
coupon_amount = StringField(
'coupon_amount',
validators=[ DataRequired(), Regexp(
r'^\d+$',
message=
'coupon_amount param error')])
pay_amount = StringField(
'pay_amount',
validators=[ DataRequired(), Regexp(
r'^\d+$',
message=
'pay_amount param error')])
coupon_form = CouponForm(request.form,
csrf_enabled=
False)
if not coupon_form.validate_on_submit():
field, errors = coupon_form.errors.items()[
0]
raise Exception(errors[
0])
转载请注明原文地址: https://ju.6miu.com/read-1125357.html