diff --git a/docs/api-guide/serializers.md b/docs/api-guide/serializers.md index 2ec98f01bf..7259cb6676 100644 --- a/docs/api-guide/serializers.md +++ b/docs/api-guide/serializers.md @@ -559,6 +559,8 @@ This option should be a list or tuple of field names, and is declared as follows Model fields which have `editable=False` set, and `AutoField` fields will be set to read-only by default, and do not need to be added to the `read_only_fields` option. +Please keep in mind that, if a field has already been explicitly declared on the serializer class (or a parent class), then the `read_only_fields` option will not apply to that field. Set `read_only=True` on the field itself instead. + !!! note There is a special-case where a read-only field is part of a `unique_together` constraint at the model level. In this case the field is required by the serializer class in order to validate the constraint, but should also not be editable by the user. @@ -591,7 +593,7 @@ This option is a dictionary, mapping field names to a dictionary of keyword argu user.save() return user -Please keep in mind that, if the field has already been explicitly declared on the serializer class, then the `extra_kwargs` option will be ignored. +Please keep in mind that, if the field has already been explicitly declared on the serializer class, then the `extra_kwargs` option will be ignored. The same is true of `read_only_fields`, which is implemented using `extra_kwargs`. ### Relational fields