Browse files

[1.8.x] Fixed #25132 -- Documented how to retrieve a single value usi…

…ng values_list() and get().

Backport of 4373eac from master
  • Loading branch information...
alexmorozov authored and timgraham committed Nov 2, 2015
1 parent 383e2e1 commit 676636ac8f2fa612d68045dd747df7bf2bf8da99
Showing with 6 additions and 0 deletions.
  1. +6 −0 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'

0 comments on commit 676636a

Please sign in to comment.