summaryrefslogtreecommitdiff
path: root/docs/ref
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:23:45 +0000
commit4373eac99828d99718a7b245d160e7e64fce2e95 (patch)
treece1494732035cb6b1eaa99980a0b3ea75f942211 /docs/ref
parentebd26bf5a5e5dce264c666bf6ef15f102903f658 (diff)
Fixed #25132 -- Documented how to retrieve a single value using values_list() and get().
Diffstat (limited to 'docs/ref')
-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 61bf4afa2c..6125cfb44a 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -625,6 +625,12 @@ It is an error to pass in ``flat`` when there is more than one field.
If you don't pass any values to ``values_list()``, it will return all the
fields in the model, in the order they were declared.
+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
~~~~~