summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-05-14 02:38:27 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-05-14 02:38:27 +0000
commitd987b378ceaa546d43f42588564515aadb0c9233 (patch)
treec4a9c39ba19bf3c7d4e27fa79c74ea421f6a7d86
parent5bdee2556e9f6b32dee8bb25ffc9594a3cb23472 (diff)
downloaddjango-d987b378ceaa546d43f42588564515aadb0c9233.tar.gz
Fixed #11039: documented that aggregation and generic relations don't mix. Thanks, psmith.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10781 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--docs/ref/contrib/contenttypes.txt15
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/ref/contrib/contenttypes.txt b/docs/ref/contrib/contenttypes.txt
index 05862bc342..f814eccaab 100644
--- a/docs/ref/contrib/contenttypes.txt
+++ b/docs/ref/contrib/contenttypes.txt
@@ -339,6 +339,21 @@ pointing at it will be deleted as well. In the example above, this means that
if a ``Bookmark`` object were deleted, any ``TaggedItem`` objects pointing at
it would be deleted at the same time.
+Generic relations and aggregation
+---------------------------------
+
+:ref:`Django's database aggregation API <topics-db-aggregation`
+doesn't work with a
+:class:`~django.contrib.contenttypes.generic.GenericRelation`. For example, you
+might be tempted to try something like::
+
+ 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 ``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.
+
Generic relations in forms and admin
------------------------------------