How custom deserialize for '@property' attribute?
gotounix opened this issue · 1 comments
gotounix commented
class Test(Model):
...
@property
def my_user(self):
return User.query.filter_by(id=1).first()
class TestSchema(ma.SQLAlchemyAutoSchema):
class Meta:
model = Node
include_fk = True
unknown = INCLUDE
my_user = ma.Nested('UserSchema')
3j14 commented
I assume you only implemented a getter for your property as defined in your example. Personally, I just use a simple Marshmallow field with dump_only=True
:
from marshmallow_sqlalchemy.fields import Nested
class TestSchema(ma.SQLAlchemyAutoSchema):
# ...
my_user = Nested('UserSchema', dump_only=True)