Open
Description
I'm trying to use a class property with the @serializable
decorator and a setter, like the sample below:
class Test(Model):
field1 = StringType(serialized_name='u_field_1')
_field2 = 'x'
@serializable(type=StringType, serialized_name='u_field_2')
def field2(self):
return self._field2
@field2.setter
def field2(self, value):
self._field2 = value
When I use the import_data()
or create a class instance using the raw_data
on __init__
, the property is never set.
Looks like the atom_filter is not able to handle fields and properties at the same time.
When I specify the validate argument the property is loaded but the field is not.
test = Test()
test.import_data({'u_field_1': 'a', 'u_field_2': 'y'}, validate=False) # this load the field1, but not the field2
test.import_data({'u_field_1': 'a', 'u_field_2': 'y'}, validate=True) # this ignore the field1, but load the field2
Metadata
Metadata
Assignees
Labels
No labels