Heim  >  Fragen und Antworten  >  Hauptteil

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 Tage vor532

Antworte allen(1)Ich werde antworten

  • 伊谢尔伦

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

    找到了个死方法,就是直接在后台更改:

    Antwort
    0
  • StornierenAntwort