summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Morozov <inductor2000@mail.ru>2015-11-02 15:42:43 +0300
committerTim Graham <timograham@gmail.com>2015-11-03 12:25:51 +0000
commit676636ac8f2fa612d68045dd747df7bf2bf8da99 (patch)
treed520838609d226f99dd2d433166077dd3955092d
parent383e2e1c53f0d1f0d1c7f09bf2f548f83c53f549 (diff)
downloaddjango-676636ac8f2fa612d68045dd747df7bf2bf8da99.tar.gz
[1.8.x] Fixed #25132 -- Documented how to retrieve a single value using values_list() and get().
Backport of 4373eac99828d99718a7b245d160e7e64fce2e95 from master
-rw-r--r--docs/ref/models/querysets.txt6
1 files changed, 6 insertions, 0 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index e6b855372a..1971964c0f 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -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
~~~~~