diff --git a/server/core/settings.py b/server/core/settings.py index c8ac4c3e..e7546779 100644 --- a/server/core/settings.py +++ b/server/core/settings.py @@ -227,8 +227,6 @@ STATICFILES_DIRS = ( os.path.join(BASE_DIR, "..", "client/src/assets"), ) -if not TEST: - STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" COMPRESS_CSS_FILTERS = [ # 'django_compressor_autoprefixer.AutoprefixerFilter', @@ -264,13 +262,24 @@ AWS_S3_CUSTOM_DOMAIN = "{}.s3-{}.amazonaws.com".format( AWS_STORAGE_BUCKET_NAME, os.environ.get("AWS_REGION", "eu-west-1") ) if USE_AWS: - DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage" + STORAGE_BACKEND = "storages.backends.s3boto3.S3Boto3Storage" # use with cloudfront MEDIA_URL = "https://%s/" % AWS_S3_CUSTOM_DOMAIN else: + STORAGE_BACKEND = "django.core.files.storage.FileSystemStorage" MEDIA_URL = "/media/" MEDIA_ROOT = os.environ.get("DJANGO_MEDIAFILES", os.path.join(BASE_DIR, "media")) +if not TEST: + STATICFILES_BACKEND = "whitenoise.storage.CompressedManifestStaticFilesStorage" +else: + STATICFILES_BACKEND = "django.contrib.staticfiles.storage.StaticFilesStorage" + +STORAGES = { + "default": {"BACKEND": STORAGE_BACKEND}, + "staticfiles": {"BACKEND": STATICFILES_BACKEND}, +} + AWS_S3_OBJECT_PARAMETERS = { "CacheControl": "max-age=86400", }