Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Marshmallow post_load returns UnmarshalResult #13

Open
PabloAlexandre opened this issue Sep 8, 2020 · 0 comments
Open

Marshmallow post_load returns UnmarshalResult #13

PabloAlexandre opened this issue Sep 8, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@PabloAlexandre
Copy link
Contributor

PabloAlexandre commented Sep 8, 2020

When Marshmallow Schema deserializes, the decorator @post_load returns a model with value. We use this model to access some attributes directly:

result = schema.loads()
print(result.attr)

Sometimes, when marshmallow lib version is incompatible with the project marshmallow version, the @post_load returns an UnmarshallResult object instead of the model value.

marshmallow-code/marshmallow#830

To fix this, we need to use result.data.attr instead of access directly the model attributes. This is a workaround, but the ideal scenario is @post_load always returns the Model instance.

@PabloAlexandre PabloAlexandre added the bug Something isn't working label Sep 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant