django models 使用auto_add_now=True时发现 时间和 电脑上时间不同,查了很多资料,实际问题很简单
django默认 USE_TZ = True, 使用的是UTC时间,改成False即可,setting.py中代码修改如下:
# TIME_ZONE = 'UTC'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
# USE_TZ = True
USE_TZ = False
django models 使用auto_add_now=True时发现 时间和 电脑上时间不同,查了很多资料,实际问题很简单
django默认 USE_TZ = True, 使用的是UTC时间,改成False即可,setting.py中代码修改如下:
# TIME_ZONE = 'UTC'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
# USE_TZ = True
USE_TZ = False