Closed sheiun closed 4 years ago
@sheiun one thing you should be able to do as a workaround is define a clean_FIELD_data
method (where FIELD
is the name of the field - from the sheet - that you need to convert). Inside that method, set the boolean value as appropriate
@steinbachr it seems still not work after define clean_{FIELD}_data
method in model.
I thought the problem is there isn't the clean_xxx_data
method in self
when execute upsert_model_data
method.
p.s. I'd updated to 0.0.9
.
one other thing to try @sheiun, can you try defining a clean_row_data
staticmethod on the model subclassing the mixin? That method takes row_data
(a dict
of row data from the sheet prior to upsert) and returns a dict
of the data which will be used for the upsert operation. Can you try doing the transform there?
one other thing to try @sheiun, can you try defining a
clean_row_data
staticmethod on the model subclassing the mixin? That method takesrow_data
(adict
of row data from the sheet prior to upsert) and returns adict
of the data which will be used for the upsert operation. Can you try doing the transform there?
Doing sth like this?
class MyModel(SheetPullableMixin, models.Model):
is_xxx = BooleanField()
@staticmethod
def clean_row_data(row_data):
row_data['is_xxx'] = row_data['is_xxx'] == 'TRUE'
return row_data
@steinbachr Thanks it works. And if doing the change in my pull request that can also transform by using clean_{field}_data
.
When I pull
TRUE
orFALSE
value from sheet it shows:But when I type
True
in sheet, it cast into all uppercase.