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 Broadcasting Stream Views

Guled Ahmed
Guled Ahmed
12,806 Points

Where did the "get_stream" method come from?

@app.route('/stream')
@app.route('/stream/<username>')
def stream(username=None):
  template = "stream.html"
  if username and username != current_user.username:
    #** - Takes care of case ex. LOVE or love
    user = models.User.select().where(models.User.username**username).get()
    stream = user.posts.limit(100)
  else:
    stream = current.get_stream().limit(100)
    user = current_user
  if username:
    template = 'user_stream.html'
    return render_template(template,stream=stream, user=user)

1 Answer

It comes from the User model