django auto_add_now时区与本地时间不同问题 解决

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

猜你喜欢

转载自blog.csdn.net/java_raylu/article/details/84558618