Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python

user.followers and user.following are already querysets, so what's a queryset?

A queryset is clearly a thing but Flask and Python documentation turn up no reference to what it is and how it works. Dogpile and Google point to Stackoverflow where it is described as a container for values but how the values get there or how it can actually be used is not clear (a lot of entries saying "you can't do that with queryset" is a mite unhelpful).

So where did Kenneth cover this and/or where can I find out how to use the bloody thing?

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 67,989 Points

I think the documentation you seek is in the Peewee docs "Query" or "SelectQuery". The term "queryset" is a more of a generic term that is also used in other frameworks such as Django QuerySet

From Django docs:

A QuerySet represents a collection of objects from your database. It can have zero, one or many filters. Filters narrow down the query results based on the given parameters. In SQL terms, a QuerySet equates to a SELECT statement, and a filter is a limiting clause such as WHERE or LIMIT.

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

A queryset is the results of a query, so the records returned by the ORM.