Skip to content

Instantly share code, notes, and snippets.

@kezabelle
Created June 19, 2019 13:57
Show Gist options
  • Save kezabelle/0ed30ab4414d3c1c670692cfaebd1411 to your computer and use it in GitHub Desktop.
Save kezabelle/0ed30ab4414d3c1c670692cfaebd1411 to your computer and use it in GitHub Desktop.
Django inconsistency around setting TZ into the environ depending on how settings are configured
>>> import os
>>> os.environ['DJANGO_SETTINGS_MODULE'] = ''
>>> from django.conf import settings
>>> settings.configure(TIME_ZONE='UTC')
>>> os.environ['TZ']
KeyError...
>>> import os
>>> os.environ['DJANGO_SETTINGS_MODULE'] = 'valid_path_to_settings'
>>> from django.conf import settings
>>> settings.TIME_ZONE
...
>>> os.environ['TZ']
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment