How to set the timezone in Django?

后端 未结 8 900
萌比男神i
萌比男神i 2020-11-29 19:33

In my django project\'s settings.py file, I have this line :

TIME_ZONE = \'UTC\'

But I want my app to run in UTC+2 timezone, s

8条回答
  •  天命终不由人
    2020-11-29 20:09

    To get a set of all valid timezone names (ids) from the tz database, you could use pytz module in Python:

    >>> import pytz # $ pip install pytz
    >>> pytz.all_timezones_set
    LazySet({'Africa/Abidjan',
             'Africa/Accra',
             'Africa/Addis_Ababa',
             'Africa/Algiers',
             'Africa/Asmara',
             'Africa/Asmera',
             ...
             'UTC',
             'Universal',
             'W-SU',
             'WET',
             'Zulu'})
    

提交回复
热议问题