Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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 68,423 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.