Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions django_oss_storage/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
from django.core.exceptions import ImproperlyConfigured, SuspiciousOperation
from django.core.files.storage import Storage
from django.conf import settings
from django.utils.encoding import force_text, force_bytes
# updated to replace force_text with force_str due to django new version deprecated this function
from django.utils.encoding import force_str, force_bytes
from django.utils.deconstruct import deconstructible
from django.utils.timezone import utc
# updated to replace django.utils.timezone with datetime.timezone.utc due to django new version deprecated this function
import datetime
from tempfile import SpooledTemporaryFile

import oss2.utils
Expand Down Expand Up @@ -83,7 +85,7 @@ def _get_key_name(self, name):
# urljoin won't work if name is absolute path
name = name.lstrip('/')

base_path = force_text(self.location)
base_path = force_str(self.location)
final_path = urljoin(base_path + "/", name)
name = os.path.normpath(final_path.lstrip('/'))

Expand Down Expand Up @@ -174,7 +176,7 @@ def get_modified_time(self, name):
file_meta = self.get_file_meta(name)

if settings.USE_TZ:
return datetime.utcfromtimestamp(file_meta.last_modified).replace(tzinfo=utc)
return datetime.utcfromtimestamp(file_meta.last_modified).replace(tzinfo=datetime.timezone.utc)
else:
return datetime.fromtimestamp(file_meta.last_modified)

Expand Down