summaryrefslogtreecommitdiff
path: root/django/conf/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/conf/__init__.py')
-rw-r--r--django/conf/__init__.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/django/conf/__init__.py b/django/conf/__init__.py
index d462f82acf..020047ffd8 100644
--- a/django/conf/__init__.py
+++ b/django/conf/__init__.py
@@ -10,7 +10,7 @@ import importlib
import os
import time
import warnings
-from pathlib import Path
+import zoneinfo
from django.conf import global_settings
from django.core.exceptions import ImproperlyConfigured
@@ -295,11 +295,9 @@ class Settings:
)
if hasattr(time, "tzset") and self.TIME_ZONE:
- # When we can, attempt to validate the timezone. If we can't find
- # this file, no check happens and it's harmless.
- zoneinfo_root = Path("/usr/share/zoneinfo")
- zone_info_file = zoneinfo_root.joinpath(*self.TIME_ZONE.split("/"))
- if zoneinfo_root.exists() and not zone_info_file.exists():
+ try:
+ zoneinfo.ZoneInfo(self.TIME_ZONE)
+ except zoneinfo.ZoneInfoNotFoundError:
raise ValueError("Incorrect timezone setting: %s" % self.TIME_ZONE)
# Move the time zone info into os.environ. See ticket #2315 for why
# we don't do this unconditionally (breaks Windows).