Your newsfeed

While we have built up most of the supporting architecture to provide the functionality for our Socializer application, we are still missing one of the more fundamental pieces of the puzzle: being able to view the posts of the people you follow in a chronological order.

To make the display of information about the owner of a post a bit simpler, let's add a relationship definition to our Post model:

class Post(db.Model):
    # …
    user = db.relationship('User',
        backref=db.backref('posts', lazy='dynamic'))

This will allow us to use post.user to access any of the user information that is associated with a given post, which is going to be quite useful in any view that displays a single post or a list of posts.

Let's add a route for this in ...

Get Flask Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.