diff options
| author | Tom Christie | 2014-11-26 11:38:48 +0000 | 
|---|---|---|
| committer | Tom Christie | 2014-11-26 11:38:48 +0000 | 
| commit | 786cab705a37f6b2196560d0e476e5c849420a61 (patch) | |
| tree | 17d7b4f195b6926cf45e5ca06aa4a453cbf9a28b /docs/api-guide | |
| parent | 5a5a73c7fef49899a37721e6c68228ef605e11f8 (diff) | |
| download | django-rest-framework-786cab705a37f6b2196560d0e476e5c849420a61.tar.bz2 | |
Tweak to 3.0 relationship docs
Diffstat (limited to 'docs/api-guide')
| -rw-r--r-- | docs/api-guide/relations.md | 12 | 
1 files changed, 11 insertions, 1 deletions
| diff --git a/docs/api-guide/relations.md b/docs/api-guide/relations.md index 7d19eba2..17009bbc 100644 --- a/docs/api-guide/relations.md +++ b/docs/api-guide/relations.md @@ -245,7 +245,7 @@ For example, the following serializer:              fields = ('order', 'title')      class AlbumSerializer(serializers.ModelSerializer): -        tracks = TrackSerializer(many=True) +        tracks = TrackSerializer(many=True, read_only=True)          class Meta:              model = Album @@ -305,6 +305,16 @@ This custom field would then serialize to the following representation.  # Further notes +## The `queryset` argument + +The `queryset` argument is only ever required for *writable* relationship field, in which case it is used for performing the model instance lookup, that maps from the primitive user input, into a model instance. + +In version 2.x a serializer class could *sometimes* automatically determine the `queryset` argument *if* a `ModelSerializer` class was being used. + +This behavior is now replaced with *always* using an explicit `queryset` argument for writable relational fields. + +Doing so reduces the amount of hidden 'magic' that `ModelSerializer` provides, makes the behavior of the field more clear, and ensures that it is trivial to move between using the `ModelSerializer` shortcut, or using fully explicit `Serializer` classes. +  ## Reverse relations  Note that reverse relationships are not automatically included by the `ModelSerializer` and `HyperlinkedModelSerializer` classes.  To include a reverse relationship, you must explicitly add it to the fields list.  For example: | 
