TypeError: can't compare offset-naive and offset-aware datetimes bugfix
and 39 can TypeError offset Compare aware
2023-09-11 14:17:21 时间
参考: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()
相关文章
- spring 2.5.6 错误:Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher
- 【Linux异常】执行man proc查看proc文档时提示错误 man: can't set the locale; make sure $LC_* and $LANG are correct No manual entry for proc
- [Typescript] Tips: Create your own 'objectKeys' function using generics and the 'keyof' operator
- [PWA] 9. Service worker registerion && service work's props, methods and listeners
- TypeError: unsupported operand type(s) for |: 'str' and 'str'
- What's the best SOAP client library for Python, and where is the documentation for it?[转]
- [Typescript] Dynamic types: Use TypeScript's Mapped Types and Template Literal Types Together
- [HTML 5 Performance] Optimize Cross-browser Images with webp and the 'picture' Element
- [Tools] Scroll, Zoom, and Highlight code in a mdx-deck slide presentation with Code Surfer <🏄/>
- [Ramda] Convert a Promise.all Result to an Object with Ramda's zip and zipObj
- [AngularJS + Unit Testing] Testing Directive's controller with bindToController, controllerAs and isolate scope
- TypeError: unsupported operand type(s) for |: 'str' and 'str'
- atitit.木马病毒webshell的原理and设计 java c# .net php.
- atitit.人脸识别的应用场景and使用最佳实践 java .net php
- Atitit.播放系统规划新版本 and 最近版本回顾 v3 pbf.doc 1 版本11 (ing)41.1 规划h5本地缓存系列 41.2 Android版本app41.3 双类别系统,
- Atitit.播放系统规划新版本 and 最近版本回顾 v3 pbf.doc
- Atitit.ati orm的设计and架构总结 适用于java c# php版
- Unable to update the EntitySet 'T_JsAPI' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
- [WPF源码分析]ContentControl依赖项属性的双向绑定,two-way binding view's DependencyProperty and ViewModel's variable