mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 12:30:11 +03:00
Merge 8ff567a06a
into 08ec276850
This commit is contained in:
commit
6b4c4b08c1
|
@ -309,7 +309,7 @@ class Field(object):
|
|||
|
||||
def __init__(self, read_only=False, write_only=False,
|
||||
required=None, default=empty, initial=empty, source=None,
|
||||
label=None, help_text=None, style=None,
|
||||
label=None, help_text=None, schema=None, style=None,
|
||||
error_messages=None, validators=None, allow_null=False):
|
||||
self._creation_counter = Field._creation_counter
|
||||
Field._creation_counter += 1
|
||||
|
@ -342,6 +342,9 @@ class Field(object):
|
|||
if validators is not None:
|
||||
self.validators = validators[:]
|
||||
|
||||
if schema is not None:
|
||||
self.schema = schema
|
||||
|
||||
# These are set up by `.bind()` when the field is added to a serializer.
|
||||
self.field_name = None
|
||||
self.parent = None
|
||||
|
|
|
@ -75,7 +75,7 @@ class PKOnlyObject(object):
|
|||
# rather than the parent serializer.
|
||||
MANY_RELATION_KWARGS = (
|
||||
'read_only', 'write_only', 'required', 'default', 'initial', 'source',
|
||||
'label', 'help_text', 'style', 'error_messages', 'allow_empty',
|
||||
'label', 'help_text', 'schema', 'style', 'error_messages', 'allow_empty',
|
||||
'html_cutoff', 'html_cutoff_text'
|
||||
)
|
||||
|
||||
|
|
|
@ -27,6 +27,9 @@ header_regex = re.compile('^[a-zA-Z][0-9A-Za-z_]*:')
|
|||
|
||||
|
||||
def field_to_schema(field):
|
||||
if hasattr(field, 'schema'):
|
||||
return field.schema
|
||||
|
||||
title = force_text(field.label) if field.label else ''
|
||||
description = force_text(field.help_text) if field.help_text else ''
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ from rest_framework.relations import Hyperlink, PKOnlyObject # NOQA # isort:ski
|
|||
# rather than the parent serializer.
|
||||
LIST_SERIALIZER_KWARGS = (
|
||||
'read_only', 'write_only', 'required', 'default', 'initial', 'source',
|
||||
'label', 'help_text', 'style', 'error_messages', 'allow_empty',
|
||||
'label', 'help_text', 'schema', 'style', 'error_messages', 'allow_empty',
|
||||
'instance', 'data', 'partial', 'context', 'allow_null'
|
||||
)
|
||||
|
||||
|
@ -1174,7 +1174,7 @@ class ModelSerializer(Serializer):
|
|||
valid_kwargs = set((
|
||||
'read_only', 'write_only',
|
||||
'required', 'default', 'initial', 'source',
|
||||
'label', 'help_text', 'style',
|
||||
'label', 'help_text', 'schema', 'style',
|
||||
'error_messages', 'validators', 'allow_null', 'allow_blank',
|
||||
'choices'
|
||||
))
|
||||
|
|
Loading…
Reference in New Issue
Block a user