"values()" returns a QuerySet of dictionaries.
For example:
print(User.objects.all().values()) # Return all fields
# <QuerySet [{'id': 1, 'name': 'John'}, {'id': 2, 'name': 'Tom'}]>
print(User.objects.all().values("name")) # Return "name" field
# <QuerySet [{'name': 'John'}, {'name': 'Tom'}]>
"values_list()" returns a QuerySet of tuples.
For example:
print(User.objects.all().values_list()) # Return all fields
# <QuerySet [(1, 'John'), (2, 'Tom')]>
print(User.objects.all().values_list("name")) # Return "name" field
# <QuerySet [('John',), ('Tom',)]>
"values_list()" with "flat=True" returns a QuerySet of values. *No or One field with "flat=True" is allowed and one field must be the 1st argument with "flat=True" which must be the 2nd argument.
For example:
print(User.objects.all().values_list(flat=True)) # Return "id" field
# <QuerySet [1, 2]>
print(User.objects.all().values_list("name", flat=True)) # Return "name" field
# <QuerySet ['John', 'Tom']>
print(User.objects.all().values_list(flat=True, "name")) # Error
print(User.objects.all().values_list("id", "name", flat=True)) # Error