marshmallow-code/marshmallow

data_key in Field does not work as load_from in version 2.x

jmontanag opened this issue · 2 comments

load_from works as if value from load_from exists it takes it, otherwise it uses field name. Unfortunately data_key does not work at same. If data_key is not in data it does not use field name, it just does not take it.

This is intended.

https://marshmallow.readthedocs.io/en/stable/upgrading.html#load-from-and-dump-to-are-merged-into-data-key

Also, when data_key is specified on a field, only data_key is checked in the input data. In marshmallow 2.x the field name is checked if load_from is missing from the input data.

Oh I see, thank you very much @lafrech