mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #23832 -- Added timezone aware Storage API.
New Storage.get_{accessed,created,modified}_time() methods convert the
naive time from now-deprecated {accessed,created_modified}_time()
methods into aware objects in UTC if USE_TZ=True.
This commit is contained in:
@@ -2,12 +2,12 @@ from datetime import datetime
|
||||
|
||||
from django.contrib.staticfiles.storage import CachedStaticFilesStorage
|
||||
from django.core.files import storage
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
class DummyStorage(storage.Storage):
|
||||
"""
|
||||
A storage class that does implement modified_time() but raises
|
||||
NotImplementedError when calling
|
||||
A storage class that implements get_modified_time().
|
||||
"""
|
||||
def _save(self, name, content):
|
||||
return 'dummy'
|
||||
@@ -18,8 +18,8 @@ class DummyStorage(storage.Storage):
|
||||
def exists(self, name):
|
||||
pass
|
||||
|
||||
def modified_time(self, name):
|
||||
return datetime.date(1970, 1, 1)
|
||||
def get_modified_time(self, name):
|
||||
return datetime.datetime(1970, 1, 1, tzinfo=timezone.utc)
|
||||
|
||||
|
||||
class SimpleCachedStaticFilesStorage(CachedStaticFilesStorage):
|
||||
|
||||
Reference in New Issue
Block a user