[Answer]-WritableField field_from_native returned value not used in Serializer

1👍

You cannot return value from field_from_native, you do it this way:

def field_from_native(self, data, files, field_name, into):
    into[field_name] = json.dumps(data.get(field_name, '{}'))

This should work as expected. Although I recommend you to use django-json-field instead. The logic of encoding/decoding field data should be embedded inside models, not the serializer.

Leave a comment