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 Logout View

Imports

Do you have to import anything besides flask?

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,454 Points

While you may get by by only importing flask, such as:

import flask

You will then have to reference every module by the full path to its functions such as:

    flask.ext.login.login_user(user)

It's better to selectively import only the functionality your need:

from flask.ext.login import (LoginManager, login_user, logout_user,
                             login_required, current_user)

    # log in user using function
    login_user(user)