口述的 Peewee 模型不包括混合 属性

Peewee model to dict doesn't include hybrid property

这是我的 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_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

当我将模型转换为字典时 model_to_dict(OAuthAccount,row) 它不包括 hybrid_property oauth_provider_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" 的可选参数,它允许您指定模型方法、属性等内容。