Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Build a Social Network with Flask Takin' Names Set up LoginManager

Oops! It looks like Task 1 is no longer passing.

I am nor sure what I am doing wrong, as I cannot see any obvious errors. I am a bit stuck here, any ideas?

Thank you!

lunch.py
from flask import Flask, g
from flask.ext.login import LoginManager

import models

app = Flask(__name__)

login_manager = LoginManager()
login_manager.init_app(app)

app.secret_key = '12345'

@login_manager.load_user
def load_user(userid):
    try:
        return models.get(models.User.id == userid)
    except models.DoesNotExist:
        return None

1 Answer

Hi Zack

There are few errors.

# it should be @login_manager.user_loader
@login_manager.user_loader
def load_user(userid):
    try:
       # your error is here, it should be models.User.get
        return models.User.get(models.User.id == userid)
    except models.DoesNotExist:
        return None

hope this helps