Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Nearly every good web app needs a way to represent a user, so we need to create our `User` model. We'll hold onto just a few fields so we can get people in and using our app as easily as possible.
Notes
order_by
can take one or more fields to order records by by default. Each field can also have a -
at the beginning to mark it as being sorted in descending order.
So why can't we do order_by = ('joined_at', 'desc')
? Because each member of the order_by
tuple is the name of a field, so that would be telling our model to order by the 'joined_at'
field and the 'desc'
field, which doesn't exist.
And since order_by
is a tuple (you can use a list if you want), we have to include that trailing comma if there's only one tuple member.
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
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