DateTimeField *** received a naive datetime (***) while time zone support is active

django报错:

/usr/local/lib/python2.7/dist-packages/Django-1.8.2-py2.7.egg/django/db/models/fields/init.py:1474: RuntimeWarning: DateTimeField Org.updatedAt received a naive datetime (2017-06-16 04:51:17) while time zone support is active.
RuntimeWarning

解决方法:

时区问题,datetime.now()生成的不带时区的utc时间称为native time
使用django.utils.timezone.now()输出的是带时区的utc时间,称为active time
懒得一个个改,so:

# from datetime import datetime # 注释的
from django.utils import timezone as datetime # 添加的

参考文献:
1、https://blog.csdn.net/heybob/article/details/77319867 2019.6.27
2、http://www.zhixing123.cn/php/django-datetimefield-received-a-naive-da.html 2019.6.27

你可能感兴趣的:(Django,报错信息)