From 296631e52c7716b128c80991fa45bca9ec94816a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Barbier?= Date: Mon, 14 Oct 2024 18:58:23 +0700 Subject: [PATCH] Define storage for static files --- src/core/settings.py | 2 +- src/core/storage_backends.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/settings.py b/src/core/settings.py index c6a9de7..2a7b9f0 100644 --- a/src/core/settings.py +++ b/src/core/settings.py @@ -97,7 +97,7 @@ AWS_S3_FILE_OVERWRITE = True STATIC_ROOT = os.path.join(BASE_DIR, 'collectstatic') # s3 static settings - STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' + STATICFILES_STORAGE = 'core.storage_backends.StaticStorage' STATIC_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/static/' DEFAULT_FILE_STORAGE = 'core.storage_backends.MediaStorage' MEDIA_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/media/' diff --git a/src/core/storage_backends.py b/src/core/storage_backends.py index b411648..a9183d1 100644 --- a/src/core/storage_backends.py +++ b/src/core/storage_backends.py @@ -2,4 +2,8 @@ class MediaStorage(S3Boto3Storage): location = 'media' - file_overwrite = False + file_overwrite = True + +class StaticStorage(S3Boto3Storage): + location = 'static' + file_overwrite = True