summaryrefslogtreecommitdiff
path: root/docs/db-api.txt
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-02-23 03:36:38 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-02-23 03:36:38 +0000
commitcbd6da3540e1116e6d049c2affd9f6894f427ace (patch)
treeb645e7dd5da5a565f4bd85410ae7bd89812d0b78 /docs/db-api.txt
parent6ad9c684aa23c62710047f94b8febc681cc30282 (diff)
queryset-refactor: Added valuelist() method to querysets. Refs #2482.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7149 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/db-api.txt')
-rw-r--r--docs/db-api.txt28
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/db-api.txt b/docs/db-api.txt
index 61bfd31882..74adc10457 100644
--- a/docs/db-api.txt
+++ b/docs/db-api.txt
@@ -664,6 +664,34 @@ followed (optionally) by any output-affecting methods (such as ``values()``),
but it doesn't really matter. This is your chance to really flaunt your
individualism.
+``valueslist(*fields)``
+~~~~~~~~~~~~~~~~~~~~~~~
+
+**New in Django development version**
+
+This is similar to ``values()`` except that instead of returning a list of
+dictionaries, it returns a list of tuples. Each tuple contains the value from
+the respective field passed into the ``valueslist()`` call -- so the first
+item is the first field, etc. For example::
+
+ >>> Entry.objects.valueslist('id', 'headling')
+ [(1, u'First entry'), ...]
+
+If you only pass in a single field, you can also pass in the ``flat``
+parameter. If ``True``, this will mean the returned results are single values,
+rather than one-tuples. An example should make the difference clearer::
+
+ >>> Entry.objects.valueslist('id').order_by('id')
+ [(1,), (2,), (3,), ...]
+
+ >>> Entry.objects.valueslist('id', flat=True).order_by('id')
+ [1, 2, 3, ...]
+
+It is an error to pass in ``flat`` when there is more than one field.
+
+If you don't pass any values to ``valueslist()``, it will return all the
+fields in the model, in the order they were declared.
+
``dates(field, kind, order='ASC')``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~