Django

Code

Changeset 8941

Show
Ignore:
Timestamp:
09/03/08 15:23:18 (4 months ago)
Author:
jacob
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/topics/serialization.txt

    r8506 r8941  
    5858~~~~~~~~~~~~~~~~ 
    5959 
    60 If you have a model that is defined using an `abstract base class`_, you don't 
    61 have to do anything special to serialize that model. Just call the serializer 
    62 on the object (or objects) that you want to serialize, and the output will be 
    63 a complete representation of the serialized object. 
     60If you have a model that is defined using an :ref:`abstract base class 
     61<abstract-base-classes>`, you don't have to do anything special to serialize 
     62that model. Just call the serializer on the object (or objects) that you want to 
     63serialize, and the output will be a complete representation of the serialized 
     64object. 
    6465 
    65 However, if you have a model that uses `multi-table inheritance`_, you also 
    66 need to serialize all of the base classes for the model. This is because only 
    67 the fields that are locally defined on the model will be serialized. For 
    68 example, consider the following models:: 
     66However, if you have a model that uses :ref:`multi-table inheritance 
     67<multi-table-inheritance>`, you also need to serialize all of the base classes 
     68for the model. This is because only the fields that are locally defined on the 
     69model will be serialized. For example, consider the following models:: 
    6970 
    70        class Place(models.Model): 
    71                name = models.CharField(max_length=50) 
     71    class Place(models.Model): 
     72        name = models.CharField(max_length=50) 
    7273 
    73        class Restaurant(Place): 
    74                serves_hot_dogs = models.BooleanField() 
     74    class Restaurant(Place): 
     75        serves_hot_dogs = models.BooleanField() 
    7576 
    7677If you only serialize the Restaurant model:: 
    7778 
    78        data = serializers.serialize('xml', Restaurant.objects.all()) 
     79    data = serializers.serialize('xml', Restaurant.objects.all()) 
    7980 
    8081the fields on the serialized output will only contain the `serves_hot_dogs` 
     
    8485serialize the Place models as well:: 
    8586 
    86         all_objects = list(Restaurant.objects.all()) + list(Place.objects.all()) 
    87         data = serializers.serialize('xml', all_objects) 
    88  
    89 .. _abstract base class: http://www.djangoproject.com/documentation/model-api/#abstract-base-classes 
    90 .. _multi-table inheritance: http://www.djangoproject.com/documentation/model-api/#multi-table-inheritance 
     87    all_objects = list(Restaurant.objects.all()) + list(Place.objects.all()) 
     88    data = serializers.serialize('xml', all_objects) 
    9189 
    9290Deserializing data