Fixed #8701, a couple of bad links in the docs.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8941 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss 2008-09-03 20:23:18 +00:00
parent d302be429b
commit 5697f87914
1 changed files with 16 additions and 18 deletions

View File

@ -57,25 +57,26 @@ be serialized.
Inherited Models Inherited Models
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
If you have a model that is defined using an `abstract base class`_, you don't If you have a model that is defined using an :ref:`abstract base class
have to do anything special to serialize that model. Just call the serializer <abstract-base-classes>`, you don't have to do anything special to serialize
on the object (or objects) that you want to serialize, and the output will be that model. Just call the serializer on the object (or objects) that you want to
a complete representation of the serialized object. 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 However, if you have a model that uses :ref:`multi-table inheritance
need to serialize all of the base classes for the model. This is because only <multi-table-inheritance>`, you also need to serialize all of the base classes
the fields that are locally defined on the model will be serialized. For for the model. This is because only the fields that are locally defined on the
example, consider the following models:: model will be serialized. For example, consider the following models::
class Place(models.Model): class Place(models.Model):
name = models.CharField(max_length=50) name = models.CharField(max_length=50)
class Restaurant(Place): class Restaurant(Place):
serves_hot_dogs = models.BooleanField() serves_hot_dogs = models.BooleanField()
If you only serialize the Restaurant model:: If you only serialize the Restaurant model::
data = serializers.serialize('xml', Restaurant.objects.all()) data = serializers.serialize('xml', Restaurant.objects.all())
the fields on the serialized output will only contain the `serves_hot_dogs` the fields on the serialized output will only contain the `serves_hot_dogs`
attribute. The `name` attribute of the base class will be ignored. attribute. The `name` attribute of the base class will be ignored.
@ -83,11 +84,8 @@ attribute. The `name` attribute of the base class will be ignored.
In order to fully serialize your Restaurant instances, you will need to In order to fully serialize your Restaurant instances, you will need to
serialize the Place models as well:: serialize the Place models as well::
all_objects = list(Restaurant.objects.all()) + list(Place.objects.all()) all_objects = list(Restaurant.objects.all()) + list(Place.objects.all())
data = serializers.serialize('xml', all_objects) 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 Deserializing data
------------------ ------------------