values, values_list, and count
Pull lightweight data and aggregates.
Why Go Lightweight
Full model objects carry every field. When you only need a column or two, lighter tools fetch less data and run faster.
values() Returns Dicts
Call values() and each row comes back as a dictionary instead of a model instance. Handy for JSON and quick reads.
Book.objects.values("title", "year")All lessons in this course
- all(), get(), and filter()
- Field Lookups and exclude()
- order_by, Slicing, and Lazy Evaluation
- values, values_list, and count