简体   繁体   中英

How to use flask_login and peewee-orm

I need to create a user loader () with flask login and peewee-orm but when I try this I end up with an error

    @login_manager.user_loader()
        def load_user(user_id):
        user = User.get(User.id == user_id)
        if user:
            return user
        return None

TypeError: user_loader() missing 1 required positional argument: 'callback'

The line @login_manager.user_loader()

should be like this :

@login_manager.user_loader

That is how you should hook a callback to a decorator anyway.

Read the Flask-login docs here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM