diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-04-12 14:46:24 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-05-17 09:36:23 +0200 |
| commit | ec186572e6cfde4cd4bc1491ff552c5d32211d9f (patch) | |
| tree | 84bfb6b786f7dfecc535347a14284032bf0a5370 /django/core/cache | |
| parent | eda12ceef16aa1a98567e25be619b05a5b3c5757 (diff) | |
Removed global timezone-aware datetime converters.
Refs #23820.
Diffstat (limited to 'django/core/cache')
| -rw-r--r-- | django/core/cache/backends/db.py | 4 |
1 files changed, 4 insertions, 0 deletions
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 " |
