Fixed #17274 -- Accepted TIME_ZONE = None when USE_TZ = True. Thanks pressureman for the report.

This problem only occured when pytz is installed. It's still strongly recommended to define the correct time zone in TIME_ZONE in order to use pytz' implementation and not the approximation based on system time.



git-svn-id: http://code.djangoproject.com/svn/django/trunk@17134 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Aymeric Augustin 2011-11-21 12:42:09 +00:00
parent c5a899b190
commit 43c5d35315
2 changed files with 15 additions and 2 deletions

View file

@ -102,8 +102,10 @@ def get_default_timezone():
"""
global _localtime
if _localtime is None:
tz = settings.TIME_ZONE
_localtime = pytz.timezone(tz) if pytz else LocalTimezone()
if isinstance(settings.TIME_ZONE, basestring) and pytz is not None:
_localtime = pytz.timezone(settings.TIME_ZONE)
else:
_localtime = LocalTimezone()
return _localtime
# This function exists for consistency with get_current_timezone_name