TypeError: can't compare offset-naive and offset-aware datetimes bugfix
Posted 朝晖
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TypeError: can't compare offset-naive and offset-aware datetimes bugfix相关的知识,希望对你有一定的参考价值。
参考:https://docs.djangoproject.com/en/1.8/topics/i18n/timezones/#naive-and-aware-datetime-objects
起因:正常的dateime.now()得到的日期不能和Django数据库里面存储的日期数据做对比,两个解决办法:
1、是把Django配置里面的USE_TZ设置成False,这样Django的数据就没有时区信息了。
2、是在这个对比情景下,不要用datetime.now()来得当前数据,用以下代码:
from django.utils import timezone now = timezone.now()
以上是关于TypeError: can't compare offset-naive and offset-aware datetimes bugfix的主要内容,如果未能解决你的问题,请参考以下文章
TypeError: can't pickle dict_values objects
TypeError: data argument can't be an iterator
TypeError: can't convert console.log(...) to primitive type
TypeError: can't compare offset-naive and offset-aware datetimes bugfix
python3.4.0 input Can't convert 'int' object to str implicitly 如何正确输出?
TypeError: can‘t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to