我有一个模型,其中有两列类型为Date
和{hybrid_property
:
@hybrid_property
def mydate_and_mytime(self):
return self.mydate.strftime("%Y-%m-%d") + " + " self.mytime.strftime("%H:%M")
但是,在属性中,self.mydate
和{InstrumentedAttribute
,它没有strftime
方法,因此会引发错误。在
如何使以下查询工作?在
^{pr2}$
除了简单的表达式,混合属性需要getter和表达式部分。利用内置函数组合日期和时间,然后格式化。在
在我看来,为了比较实际的日期时间,格式应该留给属性之外的东西,但这是你的选择。在
相关问题 更多 >
编程相关推荐