【发布时间】:2020-10-25 06:44:47
【问题描述】:
假设我的模型类如下。
class BankAccount(db.Model):
a = db.Column(db.Integer, primary_key=True)
b = db.Column(db.String(80))
我的架构如下所示。
class CreateAccountSchema(ma.SQLAlchemyAutoSchema):
class Meta:
model = BankAccount
load_instance = True
ordered = True
但在这里我想定义一个字段 c 不存在于我的模型类中,因为它应该只用于转储(ing)值而不是存储在数据库中。 有点像...
class CreateAccountSchema(ma.SQLAlchemyAutoSchema):
class Meta:
model = BankAccount
dump_only = ('c',)
load_instance = True
ordered = True
c = #somedefination
【问题讨论】:
标签: flask-sqlalchemy flask-restful marshmallow flask-marshmallow marshmallow-sqlalchemy