Hi!
I'm trying to add a calculated field to the scheme using @post_dump:
from marshmallow_jsonapi import Schema as JSONApiSchema, fields
class MyScheme(JSONApiSchema):
id = fields.Int(required=False)
is_deleted = fields.Bool(required=True)
is_enabled = fields.Bool(required=True)
is_active = fields.Bool(required=False)
class Meta:
type_ = 'my_model'
@post_dump
def is_active(self, data):
data['is_active'] = bool(not data['is_deleted'] and data['is_enabled'] )
I'm getting this error:
.../python3.7/site-packages/marshmallow_jsonapi/schema.py", line 355, in format_item
attribute = attributes[field_name]
KeyError: 'is_active'
Is there a way to make it with marshmallow-jsonapi?