mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-02 20:54:42 +03:00
Fix typos.
This commit is contained in:
parent
66a6ffaf95
commit
c5cf51cf51
|
@ -302,7 +302,7 @@ Note that reverse relationships are not automatically generated by the `ModelSer
|
|||
Instead, you must explicitly add it to the serializer. For example:
|
||||
|
||||
class AlbumSerializer(serializers.ModelSerializer):
|
||||
tracks = serializers.PrimaryKeyRelationship(many=True)
|
||||
tracks = serializers.PrimaryKeyRelatedField(many=True)
|
||||
...
|
||||
|
||||
By default, the field will uses the same accessor as it's field name to retrieve the relationship, so in this example, `Album` instances would need to have the `tracks` attribute for this relationship to work.
|
||||
|
@ -316,7 +316,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(serializers.ModelSerializer):
|
||||
tracks = serializers.PrimaryKeyRelationship(many=True, source='track_set')
|
||||
tracks = serializers.PrimaryKeyRelatedField(many=True, source='track_set')
|
||||
|
||||
See the Django documentation on [reverse relationships][reverse-relationships] for more details.
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user