From bb21216a7c7f3435ece44462beb24275bb44551a Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 7 Nov 2014 12:16:25 +0000 Subject: [PATCH] Metadata API should examine child serializer if passed parent ListSerializer. Closes #2035. --- rest_framework/metadata.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rest_framework/metadata.py b/rest_framework/metadata.py index b08d3ab67..90d3f2e01 100644 --- a/rest_framework/metadata.py +++ b/rest_framework/metadata.py @@ -96,6 +96,10 @@ class SimpleMetadata(BaseMetadata): Given an instance of a serializer, return a dictionary of metadata about its fields. """ + if hasattr(serializer, 'child'): + # If this is a `ListSerializer` then we want to examine the + # underlying child serializer instance instead. + serializer = serializer.child return OrderedDict([ (field_name, self.get_field_info(field)) for field_name, field in serializer.fields.items()