django. GenericForeginKey null when content_type and object_id is set

272 Views Asked by At

I have the following fields

content_type=models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
posted_wall = generic.GenericForeignKey('content_type', 'object_id')

And I don't get why posted_wall is None below..

(Pdb) p thread.content_type
p thread.content_type
<ContentType: foo>
(Pdb) p thread.object_id
p thread.object_id
18
(Pdb) p thread.posted_wall
p thread.posted_wall
None
(Pdb)

I noticed you can't use genericForeginKey field when filtering on queryset.
Are there other cases where I shouldn't try to access GenericForeignKey field?

EDIT

The object access is done in dehydrate_something in tastypie.
I guess the bundle.obj is not fully populated in dehydrate_FOO .

0

There are 0 best solutions below