Skip to content

Commit 3741943

Browse files
committed
Update storage config, was changed in django 4.2, removed in 5.1
1 parent 259d55f commit 3741943

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

onlineweb4/settings/storage.py

+15-11
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
S3_MEDIA_STORAGE_ENABLED = config("OW4_USE_S3", cast=bool, default=False)
44
if S3_MEDIA_STORAGE_ENABLED:
5-
from storages.backends.s3 import S3Storage
6-
75
AWS_S3_REGION_NAME = config("OW4_S3_REGION", default="eu-north-1")
86
AWS_STORAGE_BUCKET_NAME = config("OW4_S3_BUCKET_NAME")
97
AWS_S3_CUSTOM_DOMAIN = (
@@ -18,22 +16,28 @@
1816

1917
MEDIA_LOCATION = "media"
2018

21-
class MediaRootS3BotoStorage(S3Storage):
22-
def __init__(self, **kwargs):
23-
super().__init__(**(kwargs | {"location": MEDIA_LOCATION}))
24-
25-
DEFAULT_FILE_STORAGE = "onlineweb4.settings.MediaRootS3BotoStorage"
2619
MEDIA_URL = f"https://{AWS_S3_CUSTOM_DOMAIN}/{MEDIA_LOCATION}/"
2720
MEDIA_ROOT = ""
2821

2922
STATIC_LOCATION = "static"
3023

31-
class StaticRootS3BotoStorage(S3Storage):
32-
def __init__(self, **kwargs):
33-
super().__init__(**(kwargs | {"location": STATIC_LOCATION}))
3424

35-
STATICFILES_STORAGE = "onlineweb4.settings.StaticRootS3BotoStorage"
3625
STATIC_URL = f"https://{AWS_S3_CUSTOM_DOMAIN}/{STATIC_LOCATION}/"
3726

3827
WIKI_ATTACHMENTS_LOCAL_PATH = False
3928
WIKI_ATTACHMENTS_APPEND_EXTENSION = False
29+
30+
STORAGES = {
31+
"default": {
32+
"BACKEND": "storages.backends.s3.S3Storage",
33+
"OPTIONS": {
34+
"location": MEDIA_LOCATION,
35+
}
36+
},
37+
"staticfiles": {
38+
"BACKEND": "storages.backends.s3.S3Storage",
39+
"OPTIONS": {
40+
"location": STATIC_LOCATION,
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)