Rumah > Soal Jawab > teks badan
代码:
from flask_security import forms as security_forms
from flask_wtf import FlaskForm
from wtforms.fields import TextField, TextAreaField
from wtforms.validators import Required
from flask_babel import gettext as _
def unique_username(form, field):
if security_forms._datastore.find_user(nickname=field.data) is not None:
msg = security_forms.get_message(
'EMAIL_ALREADY_ASSOCIATED', email=field.data)[0]
raise security_forms.ValidationError(msg)
class ExtendedRegisterForm(security_forms.RegisterForm):
nickname = TextField(
_(u'用户名'), [security_forms.Required(), unique_username])
class SearchForm(FlaskForm):
search = TextField(_('search'), validators=[Required()])
class ReviewForm(FlaskForm):
review = TextAreaField(_('review'), validators=[Required()])
伊谢尔伦2017-04-18 09:50:36
Saya menemui cara untuk mati, iaitu menukarnya terus di latar belakang: