2015-08-20 49 views
0

這是我peewee模型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 

當我轉換模型與dict 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時在字典中包含@hybrid_property?

回答

2

我將增加一個名爲「額外的」可選PARAM,可以讓你喜歡的模型方法指定的東西,屬性等

+0

我怎麼能遵循這一未來?我應該訂閱嗎? – Alexander

+0

https://github.com/coleifer/peewee/issues/691 – coleifer