Django 管理员:尽管设置,日期时间仍以 UTC 显示
我在数据库中有这个: 25.0|120|CashApp|0.0|0|1|2022-03-03 22:05:17.025000
这在 settings.py 中:
TIME_ZONE = 'US/Eastern' # = EST
USE_I18N = True
USE_L10N = True
USE_TZ = True
在 admin.py 中:
def timestamp_(self, obj):
return obj.timestamp.strftime("%d %b, %I:%M %p") # :%S
timestamp_.admin_order_field = 'timestamp'
在页面上显示如下: 03 Mar, 10 :05 PM
据我了解,它将时间戳以 UTC 格式存储在数据库中,这是完美的,但为什么它在页面上以 UTC 格式显示它?我读过,如果我不执行 activate(),当前时区将与默认时区相同,在我的情况下应该是 EST。我缺少什么?
I have this in the DB:
25.0|120|CashApp|0.0|0|1|2022-03-03 22:05:17.025000
This in the settings.py:
TIME_ZONE = 'US/Eastern' # = EST
USE_I18N = True
USE_L10N = True
USE_TZ = True
And this in the admin.py:
def timestamp_(self, obj):
return obj.timestamp.strftime("%d %b, %I:%M %p") # :%S
timestamp_.admin_order_field = 'timestamp'
And on the page it's displayed like this: 03 Mar, 10:05 PM
From what I understand it stores the timestamp in UTC in the DB, which is perfect, but why it displays it in UTC on the page? I've read that if I don't do activate(), the current timezone will be the same as default timezone, which should be EST in my case. What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论