Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask WTform validation - unexpected keyword argument 'extra_validators'

I have simple flask user validation form in wtform:

class LoginForm(FlaskForm):
    email = StringField('Email', validators=[validators.DataRequired(), Email()])
    password = PasswordField('Password', validators=[validators.DataRequired(), validators.Length(min=8, max=20)])
    remember_me = BooleanField('Remember Me')
    submit = SubmitField('Sign In')

In my app.py file:

@app.route('/login', methods=['GET', 'POST'])
def login():
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user and bcrypt.check_password_hash(user.password, form.password.data):
            login_user(user, remember=form.remember_me.data)
            next_page = request.args.get('next')
            return redirect(next_page) if next_page else redirect(url_for('home'))
        else:
            flash('Login Unsuccessful. Please check email and password', 'danger')
    return render_template('prihl.html', title='Login', form=form)

Everything what should be is imported. I receive always Type error: TypeError: LoginForm.validate() got an unexpected keyword argument 'extra_validators'

And problem is referenced to the file "C:\Users*******.virtualenvs\flaskGPT-yypoX3qF\lib\site-packages\flask_wtf\form.py", line 86, in validate_on_submit

Is there someone who could help me with this ?

I have tried to authenticate user. Connection to the db is correct. I have migrated models succesfully. The problem is only with loginform, not with registerform.

like image 883
Vladimir Frano Avatar asked Oct 21 '25 04:10

Vladimir Frano


1 Answers

this is a known issue with version 1.1.0 of Flask-WTF and shoud be fixed in 1.1.1. Upgrading with pip install Flask-WTF --upgrade should fix this (see https://github.com/wtforms/flask-wtf/pull/548 for more details).

like image 61
ismail Avatar answered Oct 25 '25 06:10

ismail