Loading docs/topics/serialization.txt +16 −18 Original line number Diff line number Diff line Loading @@ -57,15 +57,16 @@ be serialized. Inherited Models ~~~~~~~~~~~~~~~~ If you have a model that is defined using an `abstract base class`_, you don't have to do anything special to serialize that model. Just call the serializer on the object (or objects) that you want to serialize, and the output will be a complete representation of the serialized object. If you have a model that is defined using an :ref:`abstract base class <abstract-base-classes>`, you don't have to do anything special to serialize that model. Just call the serializer on the object (or objects) that you want to serialize, and the output will be a complete representation of the serialized object. However, if you have a model that uses `multi-table inheritance`_, you also need to serialize all of the base classes for the model. This is because only the fields that are locally defined on the model will be serialized. For example, consider the following models:: However, if you have a model that uses :ref:`multi-table inheritance <multi-table-inheritance>`, you also need to serialize all of the base classes for the model. This is because only the fields that are locally defined on the model will be serialized. For example, consider the following models:: class Place(models.Model): name = models.CharField(max_length=50) Loading @@ -86,9 +87,6 @@ serialize the Place models as well:: all_objects = list(Restaurant.objects.all()) + list(Place.objects.all()) data = serializers.serialize('xml', all_objects) .. _abstract base class: http://www.djangoproject.com/documentation/model-api/#abstract-base-classes .. _multi-table inheritance: http://www.djangoproject.com/documentation/model-api/#multi-table-inheritance Deserializing data ------------------ Loading Loading
docs/topics/serialization.txt +16 −18 Original line number Diff line number Diff line Loading @@ -57,15 +57,16 @@ be serialized. Inherited Models ~~~~~~~~~~~~~~~~ If you have a model that is defined using an `abstract base class`_, you don't have to do anything special to serialize that model. Just call the serializer on the object (or objects) that you want to serialize, and the output will be a complete representation of the serialized object. If you have a model that is defined using an :ref:`abstract base class <abstract-base-classes>`, you don't have to do anything special to serialize that model. Just call the serializer on the object (or objects) that you want to serialize, and the output will be a complete representation of the serialized object. However, if you have a model that uses `multi-table inheritance`_, you also need to serialize all of the base classes for the model. This is because only the fields that are locally defined on the model will be serialized. For example, consider the following models:: However, if you have a model that uses :ref:`multi-table inheritance <multi-table-inheritance>`, you also need to serialize all of the base classes for the model. This is because only the fields that are locally defined on the model will be serialized. For example, consider the following models:: class Place(models.Model): name = models.CharField(max_length=50) Loading @@ -86,9 +87,6 @@ serialize the Place models as well:: all_objects = list(Restaurant.objects.all()) + list(Place.objects.all()) data = serializers.serialize('xml', all_objects) .. _abstract base class: http://www.djangoproject.com/documentation/model-api/#abstract-base-classes .. _multi-table inheritance: http://www.djangoproject.com/documentation/model-api/#multi-table-inheritance Deserializing data ------------------ Loading