We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 255147c commit 27265f7Copy full SHA for 27265f7
django/conf/__init__.py
@@ -103,6 +103,12 @@ def __init__(self, settings_module):
103
self.INSTALLED_APPS = new_installed_apps
104
105
if hasattr(time, 'tzset') and getattr(self, 'TIME_ZONE'):
106
+ # When we can, attempt to validate the timezone. If we can't find
107
+ # this file, no check happens and it's harmless.
108
+ zoneinfo_root = '/usr/share/zoneinfo'
109
+ if (os.path.exists(zoneinfo_root) and not
110
+ os.path.exists(os.path.join(zoneinfo_root, *(self.TIME_ZONE.split('/'))))):
111
+ raise ValueError("Incorrect timezone setting: %s" % self.TIME_ZONE)
112
# Move the time zone info into os.environ. See ticket #2315 for why
113
# we don't do this unconditionally (breaks Windows).
114
os.environ['TZ'] = self.TIME_ZONE
0 commit comments