Adapt to new storage syntax in settings

Removed the old, deprecated syntax and replaced it with the new one
This commit is contained in:
Ramon Wenger 2023-12-07 14:45:20 +01:00
parent b745afd91e
commit c47b263302
1 changed files with 12 additions and 3 deletions

View File

@ -227,8 +227,6 @@ STATICFILES_DIRS = (
os.path.join(BASE_DIR, "..", "client/src/assets"), os.path.join(BASE_DIR, "..", "client/src/assets"),
) )
if not TEST:
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
COMPRESS_CSS_FILTERS = [ COMPRESS_CSS_FILTERS = [
# 'django_compressor_autoprefixer.AutoprefixerFilter', # '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") AWS_STORAGE_BUCKET_NAME, os.environ.get("AWS_REGION", "eu-west-1")
) )
if USE_AWS: if USE_AWS:
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage" STORAGE_BACKEND = "storages.backends.s3boto3.S3Boto3Storage"
# use with cloudfront # use with cloudfront
MEDIA_URL = "https://%s/" % AWS_S3_CUSTOM_DOMAIN MEDIA_URL = "https://%s/" % AWS_S3_CUSTOM_DOMAIN
else: else:
STORAGE_BACKEND = "django.core.files.storage.FileSystemStorage"
MEDIA_URL = "/media/" MEDIA_URL = "/media/"
MEDIA_ROOT = os.environ.get("DJANGO_MEDIAFILES", os.path.join(BASE_DIR, "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 = { AWS_S3_OBJECT_PARAMETERS = {
"CacheControl": "max-age=86400", "CacheControl": "max-age=86400",
} }