Unverified Kaydet (Commit) 7fbb1bd0 authored tarafından Mariusz Felisiak's avatar Mariusz Felisiak Kaydeden (comit) GitHub

Fixed #29032 -- Fixed an example of using expressions in QuerySet.values().

üst afd50a30
...@@ -540,10 +540,10 @@ within the same ``values()`` clause. If you need to group by another value, ...@@ -540,10 +540,10 @@ within the same ``values()`` clause. If you need to group by another value,
add it to an earlier ``values()`` clause instead. For example:: add it to an earlier ``values()`` clause instead. For example::
>>> from django.db.models import Count >>> from django.db.models import Count
>>> Blog.objects.values('author', entries=Count('entry')) >>> Blog.objects.values('entry__authors', entries=Count('entry'))
<QuerySet [{'author': 1, 'entries': 20}, {'author': 1, 'entries': 13}]> <QuerySet [{'entry__authors': 1, 'entries': 20}, {'entry__authors': 1, 'entries': 13}]>
>>> Blog.objects.values('author').annotate(entries=Count('entry')) >>> Blog.objects.values('entry__authors').annotate(entries=Count('entry'))
<QuerySet [{'author': 1, 'entries': 33}]> <QuerySet [{'entry__authors': 1, 'entries': 33}]>
A few subtleties that are worth mentioning: A few subtleties that are worth mentioning:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment