Fixed #11711 -- clarified that ValuesQuerySets are not lists per se.

It rarely hurts to think of the returned result from a values() or
values_list() call as a list, but it's really an iterable and sometimes
the difference matters.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12743 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2010-03-10 03:41:41 +00:00
parent 70037f80ac
commit 1eee40234b
1 changed files with 6 additions and 6 deletions

View File

@ -361,8 +361,8 @@ query spans multiple tables, it's possible to get duplicate results when a
``values(*fields)`` ``values(*fields)``
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
Returns a ``ValuesQuerySet`` -- a ``QuerySet`` that evaluates to a list of Returns a ``ValuesQuerySet`` -- a ``QuerySet`` that returns dictionaries when
dictionaries instead of model-instance objects. used as an iterable, rather than model-instance objects.
Each of those dictionaries represents an object, with the keys corresponding to Each of those dictionaries represents an object, with the keys corresponding to
the attribute names of model objects. the attribute names of model objects.
@ -446,10 +446,10 @@ individualism.
.. versionadded:: 1.0 .. versionadded:: 1.0
This is similar to ``values()`` except that instead of returning a list of This is similar to ``values()`` except that instead of returning dictionaries,
dictionaries, it returns a list of tuples. Each tuple contains the value from it returns tuples when iterated over. Each tuple contains the value from the
the respective field passed into the ``values_list()`` call -- so the first respective field passed into the ``values_list()`` call -- so the first item is
item is the first field, etc. For example:: the first field, etc. For example::
>>> Entry.objects.values_list('id', 'headline') >>> Entry.objects.values_list('id', 'headline')
[(1, u'First entry'), ...] [(1, u'First entry'), ...]