data_key parameter not working
See original GitHub issueAs I understand the docs, I could use the data_key param if the name of the field is not the same as the key name in the dict.
data_key (str) – The name of the key to get the value from when deserializing. If None, assumes the key has the same name as the field.
However, this does not work for me. The your_name
field is not loaded from the dict. If I change the key to name
it gets loaded and the data objects now has a key your_name
. That is not what I expected based on the documentation. I am using marshmallow==2.19.2
.
>>> from marshmallow import Schema, fields
>>> class FooLoad(Schema):
... name = fields.Str(data_key='your_name')
...
>>> schema_load = FooLoad()
>>> schema_load.load({'your_name': 'qwertz'})
UnmarshalResult(data={}, errors={})
>>> schema_load.load({'name': 'qwertz'})
UnmarshalResult(data={'your_name': 'qwertz'}, errors={})
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Need help with gridview datakeys parameter! - MSDN - Microsoft
The problem is that parameters in your datasource must be types that resolve to equivalent sql types. You are attempting to bind to...
Read more >DataKeyNames coming up as undesired Update parameters ...
I am using the DataKeys for lookup purposes but I don't need them in my update ... -in-a-typed-dataset-shouuld-not-update-primary-key.
Read more >How to pass a Datakey values into parameters in telerik grid
HI I need to pass my datakey value into parameter of .Ajax.Delete() here is my Code can anyone help me to get out...
Read more >How to assign new values to ActionContextParameters ...
Question. Hello,. is it possible to assign new values to ActionContextParameters/DataKeys inside the execute(event) function of an action?
Read more >Scheduled import fails with error "Unable to import data. Key ...
Can't update record, one step is failing with error: Unable to import data. Key cannot be null. Parameter name: key CSM 7.0.2, 8.0.2,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Both
attribute
anddata_key
are used for both serialization and deserialization. They are just at the opposite end of the chain.Object ------------- Field ------------- Serialized dict attribute ------------------------------- data_key (or field name) -------------------- (or field name)
Thanks for such nice and fast replies 😃!