text: from flask_wtf import FlaskForm
  from wtforms import StringField, SubmitField, TextAreaField
  from wtforms.validators import ValidationError, DataRequired, Length, Email
  from app.models import User
  
  
  class EditProfileForm(FlaskForm):
      username = StringField('Usuário', validators=[DataRequired()])
      email = StringField('E-mail', validators=[DataRequired(), Email()])
      about_me = TextAreaField('Sobre mim', validators=[Length(min=0, max=140)])
      submit = SubmitField('Gravar')
  
      def __init__(self, original_username, original_email, *args, **kwargs):
          super(EditProfileForm, self).__init__(*args, **kwargs)
          self.original_username = original_username
          self.original_email = original_email
  
      def validate_username(self, username):
          if username.data != self.original_username:
              user = User.query.filter_by(username=self.username.data).first()
              if user is not None:
                  raise ValidationError('Por favor, use um nome diferente.')
  
      def validate_email(self, email):
          if email.data != self.original_email:
              user = User.query.filter_by(email=email.data).first()
              if user is not None:
                  raise ValidationError('Por favor use um e-mail diferente.')
  