Comments (6)
测试了一下发现这种日期会出错:
'2015-01-01 09:09:51.042000+00:00'
这种不会:
'2015-01-01 09:09:51.042000'
但是datetime直接转换就是上面那种,导致任何提到时间的语句基本都会报错,包括last_login等
from uliweb.
你可以试一下:
from uliweb.utils import date
print date.now()
看生成的时间是不是带tzinfo的信息。另外检查你是不是设置了TIMEZONE?如在uliweb shell下执行:
>>> print settings.GLOBAL.TIME_ZONE
有没有设置,缺省为None
另外我看你使用了stackless,这个我没有试过,因为生成日期的代码是在uliweb.utils.date中,为:
def now(tzinfo=None):
tz = pick_timezone(tzinfo, __timezone__)
return datetime.now(tz)
所以不太确定是不是这块有问题
from uliweb.
确实如此,settings里面加了 TIME_ZONE = 'UTC' 就会出问题。
Uliweb Command Shell
from uliweb.utils import date
print date.now()
2015-01-01 19:42:31.901000
Uliweb Command Shell
from uliweb.utils import date
print date.now()
2015-01-01 11:43:19.638000+00:00
这个是uliwebzone的默认settings
另外问题解决了,多谢
from uliweb.
我试了uliwebzone的date.now()结果类似:
datetime.datetime(2015, 1, 1, 13, 11, 33, 381305, tzinfo=<tzinfo UTC>)
而你的tzinfo是空的,不知道为什么。
from uliweb.
有的,只不过我是print出来了。
若存在 TIME_ZONE = 'UTC',结果如下:
Uliweb Command Shell
from uliweb.utils import date
date.now()
datetime.datetime(2015, 1, 2, 8, 46, 49, 627000, tzinfo=)
若不存在,如下:
Uliweb Command Shell
from uliweb.utils import date
date.now()
datetime.datetime(2015, 1, 2, 16, 46, 19, 467000)
from uliweb.
那很奇怪,我这里都是可以的。不过我是mac环境。
from uliweb.
Related Issues (20)
- Refact makecmd command
- bad runserver -h option HOT 1
- AttributeError: 'instancemethod' object has no attribute '__rule_skip__' HOT 2
- uliweb load raise UnboundLocalError
- gevent 下的 race condition HOT 31
- 多数据库 engine = get_connection(engine_name='default') 有问题 HOT 1
- orm autocreat bug HOT 3
- 开发时运行uliweb runserver错误 HOT 2
- JSON类型的字段里不能存放中文 HOT 1
- application.template and get SyntaxError exception HOT 3
- support Posgresql JSONB column?
- Cannot set Form.errors['_']
- Javascript string issue because of string strip operation of uliweb template
- wrong directory name of setup.py generated by "uliweb makemodule" HOT 1
- _generate_etag will get exception with unicode filename which cannot encode by ascii
- try to use multiple database but get exception HOT 1
- Uliweb doesn't support oracle VARCHAR2
- request.POST.copy() 非安全線程?
- 执行uliweb syncdb报错 HOT 1
- Proposing a PR to fix a few small typos
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uliweb.