mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-25 19:14:03 +03:00
Fix handling of staticfile settings if cloud provider and whitenoise are selected (#5057)
Co-authored-by: Bruno Alla <alla.brunoo@gmail.com>
This commit is contained in:
parent
f82807f53a
commit
88a9a15dbf
|
@ -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
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user