all(), get(), and filter()
The core ways to retrieve objects.
Meet the Manager
Every model gives you a free objects manager. It is your front door to the database, and every query you write starts from it. 🚪
Book.objectsGrab Everything
Call all() to ask for every row in the table. You get back a QuerySet you can loop over, count, or refine further.
books = Book.objects.all()All lessons in this course
- all(), get(), and filter()
- Field Lookups and exclude()
- order_by, Slicing, and Lazy Evaluation
- values, values_list, and count