Skip to content

Commit e801fa8

Browse files
committed
setting separate storages for static and media
1 parent 954f3cd commit e801fa8

File tree

1 file changed

+14
-3
lines changed
  • museum_of_dreams_project/settings

1 file changed

+14
-3
lines changed

museum_of_dreams_project/settings/aws.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from .base import *
2+
from storages.backends.s3boto3 import S3Boto3Storage
3+
24

35
SECRET_KEY = os.environ.get("SECRET_KEY")
46

@@ -28,8 +30,16 @@
2830
AWS_QUERYSTRING_AUTH = False # needed by grappelli to work with s3
2931

3032

31-
# DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
32-
STATICFILES_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
33+
class StaticStorage(S3Boto3Storage):
34+
location = STATIC_ROOT
35+
36+
37+
class MediaStorage(S3Boto3Storage):
38+
location = MEDIA_ROOT
39+
40+
41+
DEFAULT_FILE_STORAGE = "MediaStorage"
42+
STATICFILES_STORAGE = "StaticStorage"
3343

3444
AWS_ACCESS_KEY_ID = os.environ["AWS_ACCESS_KEY_ID"]
3545
AWS_SECRET_ACCESS_KEY = os.environ["AWS_SECRET_ACCESS_KEY"]
@@ -38,4 +48,5 @@
3848
AWS_S3_CUSTOM_DOMAIN = (
3949
f"{AWS_STORAGE_BUCKET_NAME}.s3.{AWS_S3_REGION_NAME}.amazonaws.com"
4050
)
41-
STATIC_URL = "https://%s/" % AWS_S3_CUSTOM_DOMAIN
51+
STATIC_URL = "https://%s/static" % AWS_S3_CUSTOM_DOMAIN
52+
MEDIA_URL = "https://%s/media" % AWS_S3_CUSTOM_DOMAIN

0 commit comments

Comments
 (0)