>  Q&A  >  본문

python - 用flask-security 写的登录,注册。怎么修改成中文?

代码:
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中文网2762일 전531

모든 응답(1)나는 대답할 것이다

  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:50:36

    죽는 방법을 찾았습니다. 즉, 백그라운드에서 직접 바꾸는 것입니다:

    회신하다
    0
  • 취소회신하다