From ec186572e6cfde4cd4bc1491ff552c5d32211d9f Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sun, 12 Apr 2015 14:46:24 +0200 Subject: Removed global timezone-aware datetime converters. Refs #23820. --- django/core/cache/backends/db.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'django/core') diff --git a/django/core/cache/backends/db.py b/django/core/cache/backends/db.py index a41b611d5b..6b9716b430 100644 --- a/django/core/cache/backends/db.py +++ b/django/core/cache/backends/db.py @@ -74,6 +74,8 @@ class DatabaseCache(BaseDatabaseCache): # All core backends work without typecasting, so be careful about # changes here - test suite will NOT pick regressions here. expires = typecast_timestamp(str(expires)) + if settings.USE_TZ: + expires = expires.replace(tzinfo=timezone.utc) if expires < now: db = router.db_for_write(self.cache_model_class) with connections[db].cursor() as cursor: @@ -132,6 +134,8 @@ class DatabaseCache(BaseDatabaseCache): if (connections[db].features.needs_datetime_string_cast and not isinstance(current_expires, datetime)): current_expires = typecast_timestamp(str(current_expires)) + if settings.USE_TZ: + current_expires = current_expires.replace(tzinfo=timezone.utc) exp = connections[db].ops.value_to_db_datetime(exp) if result and (mode == 'set' or (mode == 'add' and current_expires < now)): cursor.execute("UPDATE %s SET value = %%s, expires = %%s " -- cgit v1.3