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
This commit is contained in:
parent
5bdee2556e
commit
d987b378ce
|
@ -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
|
||||
------------------------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue