[1.8.x] Fixed #25132 -- Documented how to retrieve a single value using values_list() and get().

Backport of 4373eac998 from master
This commit is contained in:
Alex Morozov 2015-11-02 15:42:43 +03:00 committed by Tim Graham
parent 383e2e1c53
commit 676636ac8f
1 changed files with 6 additions and 0 deletions

View File

@ -655,6 +655,12 @@ like a list. Most of the time this is enough, but if you require an actual
Python list object, you can simply call ``list()`` on it, which will evaluate
the queryset.
A common need is to get a specific field value of a certain model instance. To
achieve that, use ``values_list()`` followed by a ``get()`` call::
>>> Entry.objects.values_list('headline', flat=True).get(pk=1)
'First entry'
dates
~~~~~