diff options
| author | Tim Graham <timograham@gmail.com> | 2015-10-05 19:07:34 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-10-06 12:38:34 -0400 |
| commit | e0837f2cb12de5e95e621d19b186b0da43bcdee2 (patch) | |
| tree | ea6ae0b150304ed18d93fb8c3ee3b7defbda0e26 /docs/ref/models | |
| parent | 3543fec3b739864c52de0a116dde3b0e5e885799 (diff) | |
Fixed #25508 -- Modified QuerySet.__repr__() to disambiguate it from a list.
Diffstat (limited to 'docs/ref/models')
| -rw-r--r-- | docs/ref/models/database-functions.txt | 2 | ||||
| -rw-r--r-- | docs/ref/models/querysets.txt | 34 |
2 files changed, 18 insertions, 18 deletions
diff --git a/docs/ref/models/database-functions.txt b/docs/ref/models/database-functions.txt index 9c9f2641b9..fc3f25dd29 100644 --- a/docs/ref/models/database-functions.txt +++ b/docs/ref/models/database-functions.txt @@ -226,7 +226,7 @@ Usage example:: >>> from django.db.models.functions import Now >>> Article.objects.filter(published__lte=Now()) - [<Article: How to Django>] + <QuerySet [<Article: How to Django>]> .. admonition:: PostgreSQL considerations diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index ebb9019784..0887e94729 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -513,11 +513,11 @@ objects:: # This list contains a Blog object. >>> Blog.objects.filter(name__startswith='Beatles') - [<Blog: Beatles Blog>] + <QuerySet [<Blog: Beatles Blog>]> # This list contains a dictionary. >>> Blog.objects.filter(name__startswith='Beatles').values() - [{'id': 1, 'name': 'Beatles Blog', 'tagline': 'All the latest Beatles news.'}] + <QuerySet [{'id': 1, 'name': 'Beatles Blog', 'tagline': 'All the latest Beatles news.'}]> The ``values()`` method takes optional positional arguments, ``*fields``, which specify field names to which the ``SELECT`` should be limited. If you specify @@ -528,9 +528,9 @@ contain a key and value for every field in the database table. Example:: >>> Blog.objects.values() - [{'id': 1, 'name': 'Beatles Blog', 'tagline': 'All the latest Beatles news.'}], + <QuerySet [{'id': 1, 'name': 'Beatles Blog', 'tagline': 'All the latest Beatles news.'}]> >>> Blog.objects.values('id', 'name') - [{'id': 1, 'name': 'Beatles Blog'}] + <QuerySet [{'id': 1, 'name': 'Beatles Blog'}]> A few subtleties that are worth mentioning: @@ -546,13 +546,13 @@ A few subtleties that are worth mentioning: For example:: >>> Entry.objects.values() - [{'blog_id': 1, 'headline': 'First Entry', ...}, ...] + <QuerySet [{'blog_id': 1, 'headline': 'First Entry', ...}, ...]> >>> Entry.objects.values('blog') - [{'blog': 1}, ...] + <QuerySet [{'blog': 1}, ...]> >>> Entry.objects.values('blog_id') - [{'blog_id': 1}, ...] + <QuerySet [{'blog_id': 1}, ...]> * When using ``values()`` together with :meth:`distinct()`, be aware that ordering can affect the results. See the note in :meth:`distinct` for @@ -585,9 +585,9 @@ individualism. You can also refer to fields on related models with reverse relations through ``OneToOneField``, ``ForeignKey`` and ``ManyToManyField`` attributes:: - Blog.objects.values('name', 'entry__headline') - [{'name': 'My blog', 'entry__headline': 'An entry'}, - {'name': 'My blog', 'entry__headline': 'Another entry'}, ...] + >>> Blog.objects.values('name', 'entry__headline') + <QuerySet [{'name': 'My blog', 'entry__headline': 'An entry'}, + {'name': 'My blog', 'entry__headline': 'Another entry'}, ...]> .. warning:: @@ -717,7 +717,7 @@ is an instance of ``EmptyQuerySet``. Examples:: >>> Entry.objects.none() - [] + <QuerySet []> >>> from django.db.models.query import EmptyQuerySet >>> isinstance(Entry.objects.none(), EmptyQuerySet) True @@ -3015,11 +3015,11 @@ as the string based lookups passed to :meth:`~django.db.models.query.QuerySet.prefetch_related()`. For example: >>> Question.objects.prefetch_related(Prefetch('choice_set')).get().choice_set.all() - [<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>] + <QuerySet [<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>]> # This will only execute two queries regardless of the number of Question # and Choice objects. >>> Question.objects.prefetch_related(Prefetch('choice_set')).all() - [<Question: Question object>] + <QuerySet [<Question: Question object>]> The ``queryset`` argument supplies a base ``QuerySet`` for the given lookup. This is useful to further filter down the prefetch operation, or to call @@ -3028,19 +3028,19 @@ relation, hence reducing the number of queries even further: >>> voted_choices = Choice.objects.filter(votes__gt=0) >>> voted_choices - [<Choice: The sky>] + <QuerySet [<Choice: The sky>]> >>> prefetch = Prefetch('choice_set', queryset=voted_choices) >>> Question.objects.prefetch_related(prefetch).get().choice_set.all() - [<Choice: The sky>] + <QuerySet [<Choice: The sky>]> The ``to_attr`` argument sets the result of the prefetch operation to a custom attribute: >>> prefetch = Prefetch('choice_set', queryset=voted_choices, to_attr='voted_choices') >>> Question.objects.prefetch_related(prefetch).get().voted_choices - [<Choice: The sky>] + <QuerySet [<Choice: The sky>]> >>> Question.objects.prefetch_related(prefetch).get().choice_set.all() - [<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>] + <QuerySet [<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>]> .. note:: |
