Python Peewee模型到dict不';不包括混合财产
这是我的皮维模型Python Peewee模型到dict不';不包括混合财产,python,dictionary,peewee,Python,Dictionary,Peewee,这是我的皮维模型 class OAuthAccount(BaseModel): id = BigIntegerField(primary_key=True,unique=True ,null = False, db_column="id") oauth_provider_id = IntegerField(null=False) oauth_uid = CharField() oauth_token = CharField() oauth_token_se
class OAuthAccount(BaseModel):
id = BigIntegerField(primary_key=True,unique=True ,null = False, db_column="id")
oauth_provider_id = IntegerField(null=False)
oauth_uid = CharField()
oauth_token = CharField()
oauth_token_secret = CharField()
username = CharField()
inserter = BigIntegerField(null=True,db_column="inserter_id")
insert_date = DateTimeField(null=True,default=fn.NOW())
updater = BigIntegerField(null=True,db_column="updater_id")
update_date = DateTimeField(null=True)
extra_data = CharField()
@hybrid_property
def oauth_provider_name(self):
return OAuthProviderEnum.getByValue(self.oauth_provider_id).label
当我将模型转换为dictmodel\u转换为dict(OAuthAccount,row)
时,它不包括hybrid\u属性oauth\u provider\u name
{
id
oauth_provider_id
oauth_uid
oauth_token
oauth_token_secret
username
inserter
insert_date
updater
update_date
extra_data
}
当使用model_to_dict时,是否可以在dict中包含@hybrid_property?我将添加一个名为“extra”的可选参数,允许您指定模型方法、属性等内容。我今后如何处理?我应该订阅吗?