This commit is contained in:
M1ha 2018-11-23 13:16:35 +05:00
parent 5add74cc39
commit e1d7db1525

View File

@ -16,10 +16,13 @@ class Django2ClickHouseModelSerializer:
data = model_to_dict(obj, self.serialize_fields, self.exclude_serialize_fields) data = model_to_dict(obj, self.serialize_fields, self.exclude_serialize_fields)
# Remove None values, they should be initialized as defaults # Remove None values, they should be initialized as defaults
params = {}
for key, value in data.items(): for key, value in data.items():
if value is None: if value is None:
del data[key] pass
elif isinstance(value, bool): elif isinstance(value, bool):
data[key] = int(value) params[key] = int(value)
else:
params[key] = value
return self._model_cls(**data) return self._model_cls(**params)