Tuesday, 2 January 2024

django timezone, and use local time instead of utc, including docker-compose

 https://docs.djangoproject.com/en/5.0/ref/settings/#std-setting-USE_TZ

https://blog.devgenius.io/dont-use-use-tz-flag-on-django-admin-app-47878e6681e6

in settings.py

TIME_ZONE = "Asia/Shanghai"

USE_I18N = True

USE_TZ = True

If change USE_TZ to False, the Django will use specified TIME_ZONE value

---------------------------------------

use together with docker-compose

  app:

    environment:

      - TZ=America/Vancouver


settings.py

import os

TIME_ZONE = os.environ.get('TZ', 'UTC')


No comments:

Post a Comment