本文介绍了取消dnago天真日期时间警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我担心涉及datetime模块的脚本.我必须禁止对象在时区处于活动状态时收到原始日期时间",因为脚本中还有其他打印语句.我的代码如下
I am concerned with a script that involves datetime module. I have to suppress 'object received a naive datetime while timezone is active' as there are other print statements in the script. My code is as below
脚本:
from datetime import datetime
date = datetime.now()
objName = className.objects.create(param=value, param=value, param=value, time=date, attachment=attachment)
models.py
models.py
class className(models.MOdel):
t = models.DateTimeField(null=True, blank=True)
如何取消朴素的日期时间警告?
How can I suppress naive datetime warnings?
推荐答案
只需禁用时区,如在文档中指出:
USE_TZ = False
这篇关于取消dnago天真日期时间警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!