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
The 'only' attribute is set only after the schema has been instantiated in the compute_schema method, and so the set of attributes that are then returned in the dump method has already been determined.
The text was updated successfully, but these errors were encountered:
A workaround is to make a call to _init_fields() after schema.only is set:
if schema.opts.type_ in qs.fields:
tmp_only = set(schema.declared_fields.keys()) & set(qs.fields[schema.opts.type_])
if schema.only:
tmp_only &= set(schema.only)
schema.only = tuple(tmp_only)
# make sure again that id field is in only parameter unless marshamllow will raise an Exception
if schema.only is not None and 'id' not in schema.only:
schema.only += ('id',)
schema._init_fields()
The 'only' attribute is set only after the schema has been instantiated in the
compute_schema
method, and so the set of attributes that are then returned in thedump
method has already been determined.The text was updated successfully, but these errors were encountered: