'Given an instance of a serializer field, return a dictionary
of metadata about it.'

def get_field_info(self, field):

    field_info = OrderedDict()
    field_info[u'type'] = self.label_lookup[field]
    field_info[u'required'] = getattr(field, u'required', False)
    attrs = [u'read_only', u'label', u'help_text', u'min_length', u'max_length', u'min_value', u'max_value']
    for attr in attrs:
        value = getattr(field, attr, None)
        if ((value is not None) and (value != u'')):
            field_info[attr] = force_text(value, strings_only=True)
    if getattr(field, u'child', None):
        field_info[u'child'] = self.get_field_info(field.child)
    elif getattr(field, u'fields', None):
        field_info[u'children'] = self.get_serializer_info(field)
    if ((not field_info.get(u'read_only')) and (not isinstance(field, (serializers.RelatedField, serializers.ManyRelatedField))) and hasattr(field, u'choices')):
        field_info[u'choices'] = [{u'value': choice_value, u'display_name': force_text(choice_name, strings_only=True)} for (choice_value, choice_name) in field.choices.items()]
    return field_info
