summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-10-29 17:38:05 -0400
committerTim Graham <timograham@gmail.com>2015-10-30 10:35:03 -0400
commite19bd086d608c981098130a49e406de91dcc3d26 (patch)
treeceea2248ae6536f4491c9916b18adc43b178ad00 /docs
parent81b55fb90078788bfdc064550f2ff9da2c79d3b6 (diff)
Fixed #24019 -- Fixed inaccurate docs about GenericRelation not supporting aggregation.
This works at least as far back as Django 1.6 according to the test added in refs #10870.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/contrib/contenttypes.txt14
1 files changed, 4 insertions, 10 deletions
diff --git a/docs/ref/contrib/contenttypes.txt b/docs/ref/contrib/contenttypes.txt
index 4a8fa22f4b..0d75739e48 100644
--- a/docs/ref/contrib/contenttypes.txt
+++ b/docs/ref/contrib/contenttypes.txt
@@ -450,18 +450,12 @@ signal.
Generic relations and aggregation
---------------------------------
-:doc:`Django's database aggregation API </topics/db/aggregation>`
-doesn't work with a
+:doc:`Django's database aggregation API </topics/db/aggregation>` works with a
:class:`~django.contrib.contenttypes.fields.GenericRelation`. For example, you
-might be tempted to try something like::
+can find out how many tags all the bookmarks have::
- Bookmark.objects.aggregate(Count('tags'))
-
-This will not work correctly, however. The generic relation adds extra filters
-to the queryset to ensure the correct content type, but the
-:meth:`~django.db.models.query.QuerySet.aggregate` method doesn't take them
-into account. For now, if you need aggregates on generic relations, you'll
-need to calculate them without using the aggregation API.
+ >>> Bookmark.objects.aggregate(Count('tags'))
+ {'tags__count': 3}
.. module:: django.contrib.contenttypes.forms