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.

Reply via email to