0Pricing
Flask Academy · Lesson

User Loader and the UserMixin

Configure the LoginManager and user model.

Meet Flask-Login

The Flask-Login extension manages who is logged in for you. It tracks the current user across requests so you do not wire sessions by hand.

pip install flask-login

Create a LoginManager

Everything starts with a LoginManager. You create one instance and connect it to your app so Flask-Login can hook into requests.

from flask_login import LoginManager
login_manager = LoginManager()
login_manager.init_app(app)

All lessons in this course

  1. Hash Passwords, Never Store Plaintext
  2. User Loader and the UserMixin
  3. login_user, logout_user, and Sessions
  4. Protect Views with login_required
← Back to Flask Academy