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

Robust Tran
Robust Tran
2,802 Points

Challenge issue

Please help me out, the challenge just indicated that I was wrong but it only showed "Try again" which make me confusing. I don't know where is the bug. :((

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

app = Flask(__name__)
app.secret_key = 'dfhd7sa897d98743^%*&hfdsjhf(*dfd'

login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'login'

@login_manager.user_loader
def load_user(user_id):
    try:
        return models.User.get(models.User.id == user_id)
    except models.User.DoseNotExist:
        return None

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

You are so VERY close! The error class should be "models.DoesNotExist" instead of " except models.User.DoseNotExist". That is, drop the "User." and change "Dose" to "Does".

Robust Tran
Robust Tran
2,802 Points

OMG, something is serious wrong with my eyes. Thanks alot :)