我的Debian服务器出现以下问题。注意:这个问题不会发生在本地Mac env上,相同的代码库。在
if self.ends < timezone.now():Exception Type: TypeError at /dealvote/Exception Value: can't compare offset-naive and offset-aware
我做了以下工作:
在中使用_TZ=True设置.py 时区='UTC'输入设置.py 安装pytz 已安装的mysql时区表mysql_tzinfo_to_sql-(如这里所建议)
代码:
^{pr2}$末端设置如下:
def setEnd(self, mins, hrs, dys):
self.ends = timezone.now()
isFlashDeal = False
try:
minutes = int(mins)
self.ends += timedelta(minutes=int(mins))
isFlashDeal = True
except Exception:
pass
try:
self.ends += timedelta(hours=int(hrs))
isFlashDeal = True
except Exception:
pass
try:
self.ends += timedelta(days=int(dys))
isFlashDeal = True
except Exception:
pass
if isFlashDeal == False:
self.ends = None
if timezone.is_naive(self.ends):
self.ends.replace(tzinfo=timezone.utc)
更改此行:
到
^{pr2}$解决了问题!在
相关问题 更多 >
编程相关推荐