python - Flask-login AttributeError: 'User' object has no attribute 'is_active' -


I have problems with flask-login after filling the login form and clicking on 'Submit' I get this error Is:

Flask-Login Attribute: There is no attribute in 'User' object 'is_active'

Some test users are created. And any problem with the login template

Traceback:

  Traceback (most recent call final): The file "C: \ flask_prj \ project \ venv \ lib \ "C: \ flask_prj \ project \ venv \ lib \ site-packages \ flask \ app.py", line 1820, in the site-packages \ flask \ expose ", line 1836, __call__ return self-vio_ app (environment, start_proc) Response = self.make_response (self.handle_exception (e)) in the wsgi_app file "C: \ flask_prj \ project \ venv \ lib \ site-packages \ flask \ app.py", line 1403, handle_exception reraise (exc_type, exc_value, tb ) In the file "C: \ flask_prj \ project \ venv \ lib \ site- Packages \ flask \ app.py ", line 1817, in the wsgi_app response = self.full_dispatch_request () file" C: \ flask_prj \ project \ venv \ lib \ site-package \ flask \ app.py ", line 1477, full_dispatch_request rv In the file "c: \ flask_prj \ project \ venv \ lib \ site-packages \ flask \ app.py", line 1381, in the file "exc:" Flask_prj \ project \ venv \ lib \ site-packages \ flask \ app.py ", Ispatch_request rv = self.dispatch_request () file in line 1475, full_d" C: \ flask_prj \ project \ venv \ lib \ site-packages \ flask \ App.py ", line 1461, in the send_refying request self.view_functions [rule.endpoint] (** req .view_args) file" C: \ flask_prj \ project \ hell OCP ", line 170, login login_user (user, form.remember_me.data) in the file" C: \ flask_prj \ project \ venv \ lib \ site-packages \ flask_login .i ", line 576, in login_user, if not No force and user. Id_active (): Attribute: Error: The 'user' object does not have any attribute 'is_active'  

View in my code:

  @ 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 the user is none and user.verify_password (form.password.data): login_user (user, form.remember_me.data) redirect redirect ('next') or url ('index' )) Return Flash ('Invalid user name or password.') Return render_template ('logi N .html ', form = form) @login_required def logout (): logout_user () Flash (' You are logged out ') Redirect redirect (url_for (' index '))  

My model:

  class user (db.Model): __tablename__ = 'user' id = db.Column (db.Integer, primary_key = true) username = db.Column (db.Integer, Unique = true, index = true) email = db Password (db.string (128)) @ property-def password (auto): attribute enter ('password is not a readable feature') column (db string (64), exclusive = true, index = true) password_hash = db.Column (db.String (128)) @ Password.setter def password (auto, password): self.password_hash = generate_password_hash (password) def verify_password (auto, password): return check_password_hash (self.password_hash, password) role_id = db Columns (DB.Entaser, DB. Forvinke ('roles.' ')) DEF __repr __ (self): Return' & lt; User% R & gt; '% Self.username'  

You will be prompted on the UserMixin Classes should be ideal. You must also add your user_loader

flask.ext.login from import from your usermixin import login_manager @ login_manager.user_loader def get_user (ident): return user.query.get (int (ident) )) Class user (db.model, usermixin) id = db. Columns (DB Integer, Primary_Keys = True) ### More Yada, you know what's here

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -