tags:

views:

29

answers:

1

Hi all, I have an object A that has two ForeignKey relations to objects B and C, and a ManyToMany relationship to object D.

When I try to get an object of type A, say a = A.objects.get(id=1), it only returns me the forign keys of the sub-objects and doesn't load them automatically.

In general I need to load all the sub-objects and serialize them to XML in my views.

Please your help.
Thanks.

+1  A: 

select_related() will help with the ForeignKeys. There's nothing you can do about the ManyToMany relations though, you'll just have to iterate through in your view.

Daniel Roseman