Author: jacob Date: 2009-05-13 21:38:27 -0500 (Wed, 13 May 2009) New Revision: 10781
Modified: django/trunk/docs/ref/contrib/contenttypes.txt Log: Fixed #11039: documented that aggregation and generic relations don't mix. Thanks, psmith. Modified: django/trunk/docs/ref/contrib/contenttypes.txt =================================================================== --- django/trunk/docs/ref/contrib/contenttypes.txt 2009-05-14 02:35:16 UTC (rev 10780) +++ django/trunk/docs/ref/contrib/contenttypes.txt 2009-05-14 02:38:27 UTC (rev 10781) @@ -339,6 +339,21 @@ 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 ------------------------------------ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---