我正在开发一个带有 Django 后端的项目(只有后端和默认管理门户,没有网站),其中管理门户由欧洲和美国的人们使用。
因此,管理门户中的日期时间以使用它的人的本地时区显示非常重要。
例如,在某些模型中,我显示实例的创建日期。我需要将这些日期显示在访问管理门户的人员的时区中。
我已经搜索了实现此目的的解决方案(例如 文档,还有这个包),但我发现的所有解决方案似乎都是为了检测访问自定义网站的最终用户的时区,而不是默认的管理门户。
我正在使用 Django 2.2 和 Python 3.8。
I'm working in a project with a Django backend (only backend and a default admin portal, no site) where the admin portal is used by people both in Europe and US.
Because of this, it's important that the datetimes in the admin portal are displayed in the local timezone of whomever is using it.
For example, in some models I display the creation date of instances. I need those dates to be displayed in the timezone of whomever accesses the admin portal.
I've searched for solutions to achieve this (such as suggested in the docs, but also this package) but all the solutions I've found seem to be made for detecting the timezone of end-users accessing a custom website, not the default admin portal.
I'm using Django 2.2 and Python 3.8.
发布评论
评论(1)
实现此目的的方法之一是使用 Django ModelAdmin 中的自定义字段。
One of the methods to achieve this is by using a custom field in Django ModelAdmin.