On Wed, Dec 31, 2008 at 4:27 AM, psj <neanderp...@gmail.com> wrote: > > Django's base serializers only serialize a model's local fields, not > inherited ones, which seems odd at first blush (if an Employee is a > Person, and a Person has a name, wouldn't I be likely to want to see > the Employees' names by default?) > > This looks straightforward to work around, but just wondering if > there's some gotcha I'm not thinking of here. Was this a performance > decision?
This is one of the areas that reveals that serialization is a bit of a 'one-trick pony'. Serialization works really well for fixtures, but it isn't particularly flexible when it comes to other serialization use cases. In this case, the serializers are serializing exactly what the database requires - the output is a JSON representation of the database table contents. The primary reason for this is the deserialization process. If you include the 'Person' attributes on a serialized Employee, it becomes more complex to determine whether you need to create a new Person object when deserializing the Employee, and to disable creation of the parent object instance when it isn't required. So - if you want to fully serialize an Employee, you also need to serialize the underlying Person object as well, and each model is responsible for serializing their own attributes. Expanding the usefulness of the serializers is something that we would like to address. If you search the ticket database, you will find many suggestions floating around for improving the capabilities of the serialization process. However, it's not a trivial problem, and it will take some serious design work. Any offers to help out in this area would be gratefully accepted. 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---