Django with system timezone setting vs user's individual timezones

前端 未结 6 519
無奈伤痛
無奈伤痛 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:49

    Update, January 2013: Django 1.4 now has time zone support!!


    Old answer for historical reasons:

    I'm going to be working on this problem myself for my application. My first approach to this problem would be to go with django core developer Malcom Tredinnick's advice in this django-user's post. You'll want to store the user's timezone setting in their user profile, probably.

    I would also highly encourage you to look into the pytz module, which makes working with timezones less painful. For the front end, I created a "timezone picker" based on the common timezones in pytz. I have one select box for the area, and another for the location (e.g. US/Central is rendered with two select boxes). It makes picking timezones slightly more convenient than wading through a list of 400+ choices.

提交回复
热议问题