From f505bd6e415fc771c920b19432dd10941a743097 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sat, 16 Aug 2008 22:44:42 +0000 Subject: [PATCH] Documented that GenericForeignKey fields can't be used transparently in filters. Refs #3006. Patch from rmyers. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8417 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/contenttypes.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/contenttypes.txt b/docs/contenttypes.txt index a07ff5d70d..84e38020bc 100644 --- a/docs/contenttypes.txt +++ b/docs/contenttypes.txt @@ -227,6 +227,16 @@ creating a ``TaggedItem``:: >>> t.content_object +Due to the way ``GenericForeignKey`` is implemeneted, you cannot use such +fields directly with filters (``filter()`` and ``exclude()``, for example) via +the database API. They aren't normal field objects. These examples will *not* +work:: + + # This will fail + >>> TaggedItem.objects.filter(content_object=guido) + # This will also fail + >>> TaggedItem.objects.get(content_object=guido) + Reverse generic relations -------------------------