Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed A Social Network with Flask!
You have completed A Social Network with Flask!
Preview
To make our app truly social, we need to add a model to represent the relationship between two users. We'll do this with a new model that has two foreign keys, both of which point back to the `User` model.
New terms
-
indexes- A list of indexes to create on the model. These could be fields to index for faster searches or, as in our case, fields to make unique. More information -
.join()- A query that references another table or another query.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Okay we need relationships in our app so
that we can actually call it social.
0:00
We'll do a pretty simple relationship
where I can follow you, but
0:00
that doesn't automatically make you follow
me.
0:03
The usual way of talking about this is
calling it an asymmetrical relationship.
0:06
We'll do that with a couple of foreign
keys and a new model, and
0:10
then we'll update our user model to add
some handy query methods for
0:13
finding out who you're following and who's
following you.
0:16
'Kay, so we need to build our relationship
model.
0:20
And we're gonna add that in down here.
0:24
And it's gonna be called class
Relationship.
0:26
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up