diff options
| author | Irindu Indeera <nbiindeera@gmail.com> | 2017-07-11 23:45:17 +0530 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-07-11 14:23:22 -0400 |
| commit | fe7b4568255ae1f77c180404631d81ba6b2d996d (patch) | |
| tree | 11abd7fd2937e8cc832975f8fa94c4e734c44494 /docs/ref/models | |
| parent | b2ebc47a22412ca8091c341b0435abc5fcc5b76e (diff) | |
[1.11.x] Fixed #28352 -- Corrected QuerySet.values_list() return type in docs examples.
Backport of babe9e64a6172b09e7f70e8d8f01e67f2cb4176d and
2457c1866ef3586c56bd19aeaa554e78c1ed1875 from master
Diffstat (limited to 'docs/ref/models')
| -rw-r--r-- | docs/ref/models/conditional-expressions.txt | 8 | ||||
| -rw-r--r-- | docs/ref/models/querysets.txt | 14 |
2 files changed, 11 insertions, 11 deletions
diff --git a/docs/ref/models/conditional-expressions.txt b/docs/ref/models/conditional-expressions.txt index 4331d1185e..af134d4561 100644 --- a/docs/ref/models/conditional-expressions.txt +++ b/docs/ref/models/conditional-expressions.txt @@ -110,7 +110,7 @@ A simple example:: ... output_field=CharField(), ... ), ... ).values_list('name', 'discount') - [('Jane Doe', '0%'), ('James Smith', '5%'), ('Jack Black', '10%')] + <QuerySet [('Jane Doe', '0%'), ('James Smith', '5%'), ('Jack Black', '10%')]> ``Case()`` accepts any number of ``When()`` objects as individual arguments. Other options are provided using keyword arguments. If none of the conditions @@ -132,7 +132,7 @@ the ``Client`` has been with us, we could do so using lookups:: ... output_field=CharField(), ... ) ... ).values_list('name', 'discount') - [('Jane Doe', '5%'), ('James Smith', '0%'), ('Jack Black', '10%')] + <QuerySet [('Jane Doe', '5%'), ('James Smith', '0%'), ('Jack Black', '10%')]> .. note:: @@ -153,7 +153,7 @@ registered more than a year ago:: ... When(account_type=Client.PLATINUM, then=a_year_ago), ... ), ... ).values_list('name', 'account_type') - [('Jack Black', 'P')] + <QuerySet [('Jack Black', 'P')]> Advanced queries ================ @@ -182,7 +182,7 @@ their registration dates. We can do this using a conditional expression and the ... ), ... ) >>> Client.objects.values_list('name', 'account_type') - [('Jane Doe', 'G'), ('James Smith', 'R'), ('Jack Black', 'P')] + <QuerySet [('Jane Doe', 'G'), ('James Smith', 'R'), ('Jack Black', 'P')]> Conditional aggregation ----------------------- diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 53e98f9ba6..951d91098c 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -635,20 +635,20 @@ respective field or expression passed into the ``values_list()`` call — so the first item is the first field, etc. For example:: >>> Entry.objects.values_list('id', 'headline') - [(1, 'First entry'), ...] + <QuerySet [(1, 'First entry'), ...]> >>> from django.db.models.functions import Lower >>> Entry.objects.values_list('id', Lower('headline')) - [(1, 'first entry'), ...] + <QuerySet [(1, '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.values_list('id').order_by('id') - [(1,), (2,), (3,), ...] + <QuerySet[(1,), (2,), (3,), ...]> >>> Entry.objects.values_list('id', flat=True).order_by('id') - [1, 2, 3, ...] + <QuerySet [1, 2, 3, ...]> It is an error to pass in ``flat`` when there is more than one field. @@ -671,10 +671,10 @@ For example, notice the behavior when querying across a :class:`~django.db.models.ManyToManyField`:: >>> Author.objects.values_list('name', 'entry__headline') - [('Noam Chomsky', 'Impressions of Gaza'), + <QuerySet [('Noam Chomsky', 'Impressions of Gaza'), ('George Orwell', 'Why Socialists Do Not Believe in Fun'), ('George Orwell', 'In Defence of English Cooking'), - ('Don Quixote', None)] + ('Don Quixote', None)]> Authors with multiple entries appear multiple times and authors without any entries have ``None`` for the entry headline. @@ -683,7 +683,7 @@ Similarly, when querying a reverse foreign key, ``None`` appears for entries not having any author:: >>> Entry.objects.values_list('authors') - [('Noam Chomsky',), ('George Orwell',), (None,)] + <QuerySet [('Noam Chomsky',), ('George Orwell',), (None,)]> .. versionchanged:: 1.11 |
