Is there a way to filter and get only specific columns?
For example, get all entries with the column first_name
.
A QuerySet is a collection of data from a database. A QuerySet is built up as a list of objects. QuerySets makes it easier to get the data you actually need, by allowing you to filter and order the data.
QuerySet.values()
or QuerySet.values_list()
, e.g.:
Entry.objects.values('first_name')
If you want a list of only the values, use:
Entry.objects.values_list('first_name', flat=True)
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