def _column2field(self, datamodel, column, nested=True, enum_dump_by_name=False):
_model = datamodel.obj<EOL>if datamodel.is_relation(column.data) and nested:<EOL><INDENT>required = not datamodel.is_nullable(column.data)<EOL>nested_model = datamodel.get_related_model(column.data)<EOL>lst = [item.data for item in column.childs]<EOL>nested_schema = self.convert(<EOL>lst,<EOL>nested_model,<EOL>nested=False<EOL>)<EOL>if datamodel.is_relation_many_to_one(column.data):<EOL><INDENT>many = False<EOL><DEDENT>elif datamodel.is_relation_many_to_many(column.data):<EOL><INDENT>many = True<EOL>required = False<EOL><DEDENT>else:<EOL><INDENT>many = False<EOL><DEDENT>field = fields.Nested(nested_schema, many=many, required=required)<EOL>field.unique = datamodel.is_unique(column.data)<EOL>return field<EOL><DEDENT>elif datamodel.is_relation(column.data):<EOL><INDENT>if (datamodel.is_relation_many_to_many(column.data) or<EOL>datamodel.is_relation_one_to_many(column.data)):<EOL><INDENT>if datamodel.get_info(column.data).get('<STR_LIT>', False):<EOL><INDENT>required = True<EOL><DEDENT>else:<EOL><INDENT>required = False<EOL><DEDENT><DEDENT>else:<EOL><INDENT>required = not datamodel.is_nullable(column.data)<EOL><DEDENT>field = field_for(_model, column.data)<EOL>field.required = required<EOL>field.unique = datamodel.is_unique(column.data)<EOL>return field<EOL><DEDENT>elif datamodel.is_enum(column.data):<EOL><INDENT>required = not datamodel.is_nullable(column.data)<EOL>enum_class = datamodel.list_columns[column.data].info.get(<EOL>'<STR_LIT>',<EOL>datamodel.list_columns[column.data].type<EOL>)<EOL>if enum_dump_by_name:<EOL><INDENT>enum_dump_by = EnumField.NAME<EOL><DEDENT>else:<EOL><INDENT>enum_dump_by = EnumField.VALUE<EOL><DEDENT>field = EnumField(enum_class, dump_by=enum_dump_by, required=required)<EOL>field.unique = datamodel.is_unique(column.data)<EOL>return field<EOL><DEDENT>if not hasattr(getattr(_model, column.data), '<STR_LIT>'):<EOL><INDENT>field = field_for(_model, column.data)<EOL>field.unique = datamodel.is_unique(column.data)<EOL>if column.data in self.validators_columns:<EOL><INDENT>field.validate.append(self.validators_columns[column.data])<EOL><DEDENT>return field<EOL><DEDENT>
:param datamodel: SQLAInterface
:param column: TreeNode column (childs are dotted column)
:param nested: Boolean if will create nested fields
:param enum_dump_by_name:
:return: Schema.field