mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 08:29:59 +03:00
fix string format and check mispelling only on read_only_fields
This commit is contained in:
parent
729b6ca188
commit
0b6b4134c7
|
@ -1386,14 +1386,15 @@ class ModelSerializer(Serializer):
|
||||||
if fields is not None:
|
if fields is not None:
|
||||||
if not isinstance(fields, (list, tuple)):
|
if not isinstance(fields, (list, tuple)):
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
f'The `{option}` option must be a list or tuple. '
|
'The `%s` option must be a list or tuple. '
|
||||||
f'Got {type(fields).__name__}.'
|
'Got %s.' % (option, type(fields).__name__)
|
||||||
)
|
)
|
||||||
for field_name in fields:
|
for field_name in fields:
|
||||||
kwargs = extra_kwargs.get(field_name, {})
|
kwargs = extra_kwargs.get(field_name, {})
|
||||||
kwargs[limit] = True
|
kwargs[limit] = True
|
||||||
extra_kwargs[field_name] = kwargs
|
extra_kwargs[field_name] = kwargs
|
||||||
else:
|
else:
|
||||||
|
if option == READ_ONLY_FIELDS:
|
||||||
# Guard against the possible misspelling `readonly_fields` (used
|
# Guard against the possible misspelling `readonly_fields` (used
|
||||||
# by the Django admin and others).
|
# by the Django admin and others).
|
||||||
assert not hasattr(self.Meta, 'readonly_fields'), (
|
assert not hasattr(self.Meta, 'readonly_fields'), (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user