Handling 404

We can control 404 errors and bad requests using the abort() function provided by flask. What it does is that […]

Read More
Comments Off on Handling 404

Viewing Followed Posts

[models.py] class User(UserMixin, Model): …. def get_stream(self): return Post.select().where( (Post.user << self.following()) | (Post.user == self) ) def following(self): …. […]

Read More
Comments Off on Viewing Followed Posts

Showing Followers

[user_stream.html] … <div class=”grid-25″> <h5>Followers</h5> <p>{{ user.followers().count() }}</p> </div> <div class=”grid-25″> <h5>Following</h5> <p>{{ user.following().count() }}</p> </div> … <div class=”grid-25″> {% […]

Read More
Comments Off on Showing Followers

Relationship Model & Views

Relationship Model [models.py] … class User(UserMixin, Model): … def following(self): “””Users that current user follows.””” return User.select().join( Relationship, on=Relationship.to_user ).where( […]

Read More
Comments Off on Relationship Model & Views