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

Flask Social Media challenge

Add a view named follow with a route of "/follow/<int:user_id>". It should be login_required. In the view, create a new Relationship with the current user as the from_user and the user with the provided ID as the to_user. Return a redirect to index.

Bummer: SyntaxError: return redirect(url_for('index'))

@app.route('/follow/<int:user_id>')
@login_required
def follow(user_id):
    try:
        models.Relationship.create(
            from_user = g.user._get_current_object(),
            to_user = user_id
        )
    return redirect(url_for('index'))