diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index 0cebe1d9..72f92cc2 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -118,7 +118,7 @@ AZURE_CONTAINER = env("DJANGO_AZURE_CONTAINER_NAME") # STATIC & MEDIA # ------------------------ STORAGES = { -{%- if cookiecutter.use_whitenoise == 'y' %} +{%- if cookiecutter.use_whitenoise == 'y' and cookiecutter.cloud_provider == 'None' %} "default": { "BACKEND": "django.core.files.storage.FileSystemStorage", }, @@ -133,6 +133,11 @@ STORAGES = { "file_overwrite": False, }, }, + {%- if cookiecutter.use_whitenoise == 'y' %} + "staticfiles": { + "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage", + }, + {%- else %} "staticfiles": { "BACKEND": "storages.backends.s3.S3Storage", "OPTIONS": { @@ -140,6 +145,7 @@ STORAGES = { "default_acl": "public-read", }, }, + {%- endif %} {%- elif cookiecutter.cloud_provider == 'GCP' %} "default": { "BACKEND": "storages.backends.gcloud.GoogleCloudStorage", @@ -148,6 +154,11 @@ STORAGES = { "file_overwrite": False, }, }, + {%- if cookiecutter.use_whitenoise == 'y' %} + "staticfiles": { + "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage", + }, + {%- else %} "staticfiles": { "BACKEND": "storages.backends.gcloud.GoogleCloudStorage", "OPTIONS": { @@ -155,6 +166,7 @@ STORAGES = { "default_acl": "publicRead", }, }, + {%- endif %} {%- elif cookiecutter.cloud_provider == 'Azure' %} "default": { "BACKEND": "storages.backends.azure_storage.AzureStorage", @@ -163,28 +175,40 @@ STORAGES = { "file_overwrite": False, }, }, + {%- if cookiecutter.use_whitenoise == 'y' %} + "staticfiles": { + "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage", + }, + {%- else %} "staticfiles": { "BACKEND": "storages.backends.azure_storage.AzureStorage", "OPTIONS": { "location": "static", }, }, + {%- endif %} {%- endif %} } {%- endif %} {%- if cookiecutter.cloud_provider == 'AWS' %} MEDIA_URL = f"https://{aws_s3_domain}/media/" +{%- if cookiecutter.use_whitenoise == 'n' %} COLLECTFAST_STRATEGY = "collectfast.strategies.boto3.Boto3Strategy" STATIC_URL = f"https://{aws_s3_domain}/static/" +{%- endif %} {%- elif cookiecutter.cloud_provider == 'GCP' %} MEDIA_URL = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/media/" +{%- if cookiecutter.use_whitenoise == 'n' %} COLLECTFAST_STRATEGY = "collectfast.strategies.gcloud.GoogleCloudStrategy" STATIC_URL = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/static/" +{%- endif %} {%- elif cookiecutter.cloud_provider == 'Azure' %} MEDIA_URL = f"https://{AZURE_ACCOUNT_NAME}.blob.core.windows.net/media/" +{%- if cookiecutter.use_whitenoise == 'n' %} STATIC_URL = f"https://{AZURE_ACCOUNT_NAME}.blob.core.windows.net/static/" {%- endif %} +{%- endif %} # EMAIL # ------------------------------------------------------------------------------