def add_field(self, field): """ Adds a field to this table :param field: This can be a string of a field name, a dict of {'alias': field}, or a ``Field`` instance :type field: str or dict or Field """ field = FieldFactory( field, ) field.set_table(self) # make sure field is not already added field_name = field.get_name() for existing_field in self.fields: if existing_field.get_name() == field_name: return None self.before_add_field(field) field.before_add() if field.ignore is False: self.fields.append(field) return field
def add_field(self, field): """ Adds a field to this table :param field: This can be a string of a field name, a dict of {'alias': field}, or a ``Field`` instance :type field: str or dict or Field """ field = FieldFactory(field, ) field.set_table(self) # make sure field is not already added field_name = field.get_name() for existing_field in self.fields: if existing_field.get_name() == field_name: return None self.before_add_field(field) field.before_add() if field.ignore is False: self.fields.append(field) return field