mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 04:50:12 +03:00
Merge b3abe12ef1
into bd768d6253
This commit is contained in:
commit
9471177bd2
|
@ -124,12 +124,13 @@ class SimpleMetadata(BaseMetadata):
|
||||||
attrs = [
|
attrs = [
|
||||||
'read_only', 'label', 'help_text',
|
'read_only', 'label', 'help_text',
|
||||||
'min_length', 'max_length',
|
'min_length', 'max_length',
|
||||||
'min_value', 'max_value'
|
'min_value', 'max_value',
|
||||||
|
'initial'
|
||||||
]
|
]
|
||||||
|
|
||||||
for attr in attrs:
|
for attr in attrs:
|
||||||
value = getattr(field, attr, None)
|
value = getattr(field, attr, None)
|
||||||
if value is not None and value != '':
|
if value is not None and value != '' and value != []:
|
||||||
field_info[attr] = force_text(value, strings_only=True)
|
field_info[attr] = force_text(value, strings_only=True)
|
||||||
|
|
||||||
if getattr(field, 'child', None):
|
if getattr(field, 'child', None):
|
||||||
|
|
|
@ -77,7 +77,8 @@ class TestMetadata:
|
||||||
min_value=1, max_value=1000
|
min_value=1, max_value=1000
|
||||||
)
|
)
|
||||||
char_field = serializers.CharField(
|
char_field = serializers.CharField(
|
||||||
required=False, min_length=3, max_length=40
|
required=False, min_length=3, max_length=40,
|
||||||
|
initial='initial value'
|
||||||
)
|
)
|
||||||
list_field = serializers.ListField(
|
list_field = serializers.ListField(
|
||||||
child=serializers.ListField(
|
child=serializers.ListField(
|
||||||
|
@ -136,7 +137,8 @@ class TestMetadata:
|
||||||
'read_only': False,
|
'read_only': False,
|
||||||
'label': 'Char field',
|
'label': 'Char field',
|
||||||
'min_length': 3,
|
'min_length': 3,
|
||||||
'max_length': 40
|
'max_length': 40,
|
||||||
|
'initial': 'initial value'
|
||||||
},
|
},
|
||||||
'list_field': {
|
'list_field': {
|
||||||
'type': 'list',
|
'type': 'list',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user