Returns a QuerySet that returns dictionaries
, rather than model instances, when used as an iterable.
Returns a QuerySet that returns list of tuples
, rather than model instances, when used as an iterable.
distinct are used to eliminate the duplicate
elements.
Example:
>>> list(Article.objects.values_list('id', flat=True)) # flat=True will remove the tuples and return the list
[1, 2, 3, 4, 5, 6]
>>> list(Article.objects.values('id'))
[{'id':1}, {'id':2}, {'id':3}, {'id':4}, {'id':5}, {'id':6}]