>From the django doc "Due to the way GenericForeignKey is implemented, you cannot use such fields directly with filters (filter() and exclude(), for example) via the database API. They aren't normal field objects."
http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#generic-relations On Dec 6, 6:24 pm, Katrina <katrina.m.elli...@gmail.com> wrote: > I have a model set up thusly: > > from django.contrib.contenttypes.models import ContentType > from django.contrib.contenttypes import generic > > Item(models.Model): > content_type = models.ForeignKey(ContentType) > object_id = models.PositiveIntegerField() > object = generic.GenericForeignKey() > > If I try to perform queries in the format > Item.objects.filter(object=some-object), I raise a FieldError: "Cannot > resolve keyword 'object' into field". But if I have some instance of > Item and I call item-instance.object, it returns the object correctly. > > Is this a behavioral malfunction, or are Generic ForeignKeys not meant > to be used in database queries? If they are not, is there any real > advantage to having one? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.