def parse_field(self, field_data, index=0):
        """Parse field and add missing options"""
        field = {
            '__index__': index,
        }

        if isinstance(field_data, str):
            field.update(self.parse_string_field(field_data))
        elif isinstance(field_data, dict):
            field.update(field_data)
        else:
            raise TypeError('Expected a str or dict get {}'.format(type(field_data)))

        if 'field' not in field:
            field['field'] = None

        if 'label' not in field and field['field']:
            try:
                field['label'] = self.object._meta.get_field(field['field']).verbose_name.capitalize()
            except Exception:
                field['label'] = field['field'].replace('_', '').capitalize()
        elif 'label' not in field:
            field['label'] = ''

        if 'format' not in field:
            field['format'] = '{0}'

        # Set default options
        for name, options in self.fields_options.items():
            if 'default' in options and name not in field:
                field[name] = options['default']

        return field
def parse_field ( self , field_data , index = 0 ) : field = { '__index__' : index , } if isinstance ( field_data , str ) : field . update ( self . parse_string_field ( field_data ) ) elif isinstance ( field_data , dict ) : field . update ( field_data ) else : raise TypeError ( 'Expected a str or dict get {}' . format ( type ( field_data ) ) ) if 'field' not in field : field [ 'field' ] = None if 'label' not in field and field [ 'field' ] : try : field [ 'label' ] = self . object . _meta . get_field ( field [ 'field' ] ) . verbose_name . capitalize ( ) except Exception : field [ 'label' ] = field [ 'field' ] . replace ( '_' , '' ) . capitalize ( ) elif 'label' not in field : field [ 'label' ] = '' if 'format' not in field : field [ 'format' ] = '{0}' for name , options in self . fields_options . items ( ) : if 'default' in options and name not in field : field [ name ] = options [ 'default' ] return field
Parse field and add missing options