On Jan 24, 2008 9:57 PM, sector119 <[EMAIL PROTECTED]> wrote: > > Hi All! > > I get a trouble when I try to serialize object with many-to-many > relationship. All related objects have no values in xml, in db > everything is ok, why? > > <field to="transactions.servicetransactions" name="transactions" > rel="ManyToManyRel"> > > # HERE IS NO VALUES IN OBJECTS, WHY?
There are no values because m2m relations are serialized as a list of IDs for the related objects, not a list of full included objects. This is because you could end up with duplicated data (if you have 2 m2m relations on the same model, a single instance could be included in both relations), or worse - circular relationships between models. If you want the data for the objects that are referred to, you will need to serialize those models too (i.e., if Author has an m2m relation on Book, you need to serialize Author _and_ Book, not just Author) Yours, Russ Magee %-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---