Browse files

Fixed #11039: documented that aggregation and generic relations don't…

… mix. Thanks, psmith.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 5bdee25 commit d987b378ceaa546d43f42588564515aadb0c9233 @jacobian jacobian committed May 14, 2009
Showing with 15 additions and 0 deletions.
  1. +15 −0 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

0 comments on commit d987b37

Please sign in to comment.