时间:2021-07-01 10:21:17 帮助过:6人阅读
解决方案:
修改settings.py中时区配置信息:
# LANGUAGE_CODE = ‘en-us‘ # # TIME_ZONE = ‘Asia/Shanghai‘ # # USE_I18N = True # # USE_L10N = True # # USE_TZ = True # 解决Database returned an invalid datetime value. Are time zone definitions for your database installed? LANGUAGE_CODE = ‘zh-hans‘ TIME_ZONE = ‘Asia/Shanghai‘ USE_I18N = True USE_L10N = True
注意问题:
启用 USE_TZ = True 后,处理时间方面,有两条 “黄金法则”:
保证存储到数据库中的是 UTC 时间;
在函数之间传递时间参数时,确保时间已经转换成 UTC 时间;
解决Database returned an invalid datetime value. Are time zone definitions for your database installed?
标签:tin 问题 转换 -- setting lis user ali 时间