Django docs specify when queryset gets evaluated.
When does ValuesListQuerySet, ValuesQuerySet evaluated? (when does it hit the DB?)
Django values_list() is an optimization to grab specific data from the database instead of building and loading the entire model instance.
This is because a Django QuerySet is a lazy object. It contains all of the information it needs to populate itself from the database, but will not actually do so until the information is needed.
It acts the same as any normal QuerySet
, just its output is transformed directly from model instances to dictionaries/tuples respectively before being passed on to you, as per https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.values
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With