I encountered this error when using the flask (web framework) framework as the login module.
AttributeError: ‘User’ object has no attribute ‘is_active’
Relevant code segment:
@auth.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 is not None and user.verify_password(form.password.data):
login_user(user, form.remember_me.data)
return redirect(request.args.get('next') or url_for('main.index'))
flash('Invalid username or password.')
return render_template('auth/login.html', form=form)
I don’t know what’s wrong, who can help me look at it?
There is no is_active in the database model of User, your user, no inheritance, UserMixin,
http://flask-login.readthedocs.org/en/latest/#flask.ext.login.UserMixin
http://docs.jinkan.org/docs/flask-login/
http://www.oschina.net/translate/the-flask-mega-tutorial-part-v-user-logins
Two methods,
One is written by yourself, the other is inherited from him.