aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide/relations.md
diff options
context:
space:
mode:
authorTom Christie2013-02-19 17:09:28 +0000
committerTom Christie2013-02-19 17:09:28 +0000
commit66a6ffaf957405691d0714fc422b46a6927639a7 (patch)
tree2856928bee9c6d38fac15d49734541ff6f15c125 /docs/api-guide/relations.md
parent618606888ab34418998d1abfe4668804038ff22f (diff)
downloaddjango-rest-framework-66a6ffaf957405691d0714fc422b46a6927639a7.tar.bz2
Fix typos.
Diffstat (limited to 'docs/api-guide/relations.md')
-rw-r--r--docs/api-guide/relations.md20
1 files changed, 10 insertions, 10 deletions
diff --git a/docs/api-guide/relations.md b/docs/api-guide/relations.md
index 25fca475..5a9d74b0 100644
--- a/docs/api-guide/relations.md
+++ b/docs/api-guide/relations.md
@@ -43,7 +43,7 @@ In order to explain the various types of relational fields, we'll use a couple o
For example, the following serializer.
- class AlbumSerializer(serializer.ModelSerializer):
+ class AlbumSerializer(serializers.ModelSerializer):
tracks = RelatedField(many=True)
class Meta:
@@ -75,7 +75,7 @@ This field is read only.
For example, the following serializer:
- class AlbumSerializer(serializer.ModelSerializer):
+ class AlbumSerializer(serializers.ModelSerializer):
tracks = PrimaryKeyRelatedField(many=True, read_only=True)
class Meta:
@@ -109,7 +109,7 @@ By default this field is read-write, although you can change this behavior using
For example, the following serializer:
- class AlbumSerializer(serializer.ModelSerializer):
+ class AlbumSerializer(serializers.ModelSerializer):
tracks = HyperlinkedRelatedField(many=True, read_only=True,
view_name='track-detail')
@@ -149,7 +149,7 @@ By default this field is read-write, although you can change this behavior using
For example, the following serializer:
- class AlbumSerializer(serializer.ModelSerializer):
+ class AlbumSerializer(serializers.ModelSerializer):
tracks = SlugRelatedField(many=True, read_only=True, slug_field='title')
class Meta:
@@ -223,12 +223,12 @@ Note that nested relationships are currently read-only. For read-write relation
For example, the following serializer:
- class TrackSerializer(serializer.ModelSerializer):
+ class TrackSerializer(serializers.ModelSerializer):
class Meta:
model = Track
fields = ('order', 'title')
- class AlbumSerializer(serializer.ModelSerializer):
+ class AlbumSerializer(serializers.ModelSerializer):
tracks = TrackSerializer(many=True)
class Meta:
@@ -265,7 +265,7 @@ For, example, we could define a relational field, to serialize a track to a cust
duration = time.strftime('%M:%S', time.gmtime(value.duration))
return 'Track %d: %s (%s)' % (value.order, value.name, duration)
- class AlbumSerializer(serializer.ModelSerializer):
+ class AlbumSerializer(serializers.ModelSerializer):
tracks = TrackListingField(many=True)
class Meta:
@@ -295,13 +295,13 @@ Note that reverse relationships are not automatically generated by the `ModelSer
**The following will not work:**
- class AlbumSerializer(serializer.ModelSerializer):
+ class AlbumSerializer(serializers.ModelSerializer):
class Meta:
fields = ('tracks', ...)
Instead, you must explicitly add it to the serializer. For example:
- class AlbumSerializer(serializer.ModelSerializer):
+ class AlbumSerializer(serializers.ModelSerializer):
tracks = serializers.PrimaryKeyRelationship(many=True)
...
@@ -315,7 +315,7 @@ The best way to ensure this is typically to make sure that the relationship on t
Alternatively, you can use the `source` argument on the serializer field, to use a different accessor attribute than the field name. For example.
- class AlbumSerializer(serializer.ModelSerializer):
+ class AlbumSerializer(serializers.ModelSerializer):
tracks = serializers.PrimaryKeyRelationship(many=True, source='track_set')
See the Django documentation on [reverse relationships][reverse-relationships] for more details.