Django with system timezone setting vs user's individual timezones

前端 未结 6 516
無奈伤痛
無奈伤痛 2021-02-02 15:01

How well does Django handle the case of different timezones for each user? Ideally I would like to run the server in the UTC timezone (eg, in settings.py set TIME_ZONE=\"UTC\")

6条回答
  •  别跟我提以往
    2021-02-02 15:39

    Looking at the django-timezones application I found that it doesn't support MySQL DBMS, since MySQL doesn't store any timezone reference within datetimes.

    Well, I think I manage to work around this by forking the Brosner library and modifying it to work transparently within your models.

    There, I'm doing the same thing the django translation system do, so you can get user unique timezone conversion. There you should find a Field class and some datetime utils to always get datetimes converted to the user timezone. So everytime you make a request and do a query, everything will be timezoned.

    Give it a try!

提交回复
热议问题