You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tested with a @pre_dump method, i got the Model instance and was able to access Model.data as a python dict.
Then i used @post_dump, but then data["data"] was a malformed JSON string (it used single quotes).
So, the problem is inside how marshmallow-sqlalchemy transforms the SQLA object.
For now i solved it adding a @post_dump method, this gives me the data["data"] as a python dict.
classVerificationSchema(ma.SQLAlchemyAutoSchema):
classMeta:
model=VerificationDatainclude_fk=True@decorators.post_dumpdefdeserialize_pickle_bin(self, data, **kwargs):
# For some reason, marshmallow serializes the dict to a string.# So this is nesessary.data["data"] =json.loads(data["data"].replace("'", "\""))
returndata
But I think this should be default behaviour.
The text was updated successfully, but these errors were encountered:
I have a SQLA model:
Then auto create a Marshmallow Schema:
I tested with a
@pre_dump
method, i got the Model instance and was able to accessModel.data
as a python dict.Then i used
@post_dump
, but thendata["data"]
was a malformed JSON string (it used single quotes).So, the problem is inside how marshmallow-sqlalchemy transforms the SQLA object.
For now i solved it adding a
@post_dump
method, this gives me thedata["data"]
as a python dict.But I think this should be default behaviour.
The text was updated successfully, but these errors were encountered: