mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 11:33:59 +03:00
Merge pull request #3104 from Seraf/master
Adding recursion on child of List Field
This commit is contained in:
commit
c3507552d5
|
@ -131,6 +131,9 @@ class SimpleMetadata(BaseMetadata):
|
||||||
if value is not None and value != '':
|
if value is not None 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):
|
||||||
|
field_info['child'] = self.get_field_info(field.child)
|
||||||
|
|
||||||
if not field_info.get('read_only') and hasattr(field, 'choices'):
|
if not field_info.get('read_only') and hasattr(field, 'choices'):
|
||||||
field_info['choices'] = [
|
field_info['choices'] = [
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,6 +67,11 @@ class TestMetadata:
|
||||||
char_field = serializers.CharField(
|
char_field = serializers.CharField(
|
||||||
required=False, min_length=3, max_length=40
|
required=False, min_length=3, max_length=40
|
||||||
)
|
)
|
||||||
|
list_field = serializers.ListField(
|
||||||
|
child=serializers.ListField(
|
||||||
|
child=serializers.IntegerField()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
class ExampleView(views.APIView):
|
class ExampleView(views.APIView):
|
||||||
"""Example view."""
|
"""Example view."""
|
||||||
|
@ -119,6 +124,22 @@ class TestMetadata:
|
||||||
'label': 'Char field',
|
'label': 'Char field',
|
||||||
'min_length': 3,
|
'min_length': 3,
|
||||||
'max_length': 40
|
'max_length': 40
|
||||||
|
},
|
||||||
|
'list_field': {
|
||||||
|
'type': 'list',
|
||||||
|
'required': True,
|
||||||
|
'read_only': False,
|
||||||
|
'label': 'List field',
|
||||||
|
'child': {
|
||||||
|
'type': 'list',
|
||||||
|
'required': True,
|
||||||
|
'read_only': False,
|
||||||
|
'child': {
|
||||||
|
'type': 'integer',
|
||||||
|
'required': True,
|
||||||
|
'read_only': False
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user