我的一个模型中有以下代码:
def shortDescription(self):
return self.name + ' ' + self.class_date.strftime("%I:%M")
self.class_date
是时区意识DateTimeField
,self.class_date.is_aware()
是True
,USE_TZ
是True
。
shortDescription 返回一个字符串,该字符串以 UTC 而非默认时区给出时间,放入{{ aclass.class_date }}
模板中会显示正确时区的时间。
总是strftime
在基地工作,本地时间?或者这里发生了什么?