python - 用flask-security 写的登录,注册。怎么修改成中文?
PHP中文网
PHP中文网 2017-04-18 09:48:36
0
1
369

代码:
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()])
PHP中文网
PHP中文网

认证0级讲师

全部回复(1)
热门教程
더>
最新下载
더>
网站特效
网站源码
网站素材
프론트엔드 템플릿
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!