目前to_dict()直接使用 get_value_for_datastore() 来获得数据,它只是把保存数据库的值直接取出来,不会进行转换。可以使用
from uliweb.utils import date
date.to_local(d)
来进行转换。如果方便,还可以考虑在to_dict()上加一个to_local的参数,如果为True,则自动转成本地时区,这个方式如何?不过使用时区,date和time就不合适了,可能要使用datetime
On Sat, Feb 25, 2017 at 4:38 PM, SeedSeek <frt5...@gmail.com> wrote:
> OS: Linux
> uliweb: github 提交時間 Feb 19, 2017
> settings.ini
> TIME_ZONE = 'GMT +8'
> LOCAL_TIME_ZONE = 'GMT +0'
>
> 使用 Model.to_dict() 不會對 datetime 做轉換。 to_dict() 本身不支持timezone 轉換?
>
>
>
> --
> -- ----
> Project : https://github.com/limodou/uliweb
> doc : http://limodou.github.com/uliweb-doc
> ---
> You received this message because you are subscribed to the Google Groups
> "Uliweb" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to uliweb+unsubscribe@googlegroups.com.
> To post to this group, send email to uli...@googlegroups.com.
> Visit this group at https://groups.google.com/group/uliweb.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/uliweb/1914a271-4abb-4c7c-895b-602e7ff6f446%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
I like python!
UliPad <<The Python Editor>>: http://code.google.com/p/ulipad/
UliWeb <<simple web framework>>: https://github.com/limodou/uliweb
My Blog: http://my.oschina.net/limodou
--
-- ----
Project : https://github.com/limodou/uliweb
doc : http://limodou.github.com/uliweb-doc
---
You received this message because you are subscribed to the Google Groups "Uliweb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uliweb+unsubscribe@googlegroups.com.
To post to this group, send email to uli...@googlegroups.com.
Visit this group at https://groups.google.com/group/uliweb.
To view this discussion on the web visit https://groups.google.com/d/msgid/uliweb/CADCtg99jYTTearEgNweCpBxXHzByfnxcjuwyhe8xsXYyba4JsQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/uliweb/CAHLXMV9HQy3e-MXPn8tFtuViiQucN7gQ0Zn1GEXjA1D1xXZuWA%40mail.gmail.com.