From b4cea81f260b686be0678706fa60da4067c86669 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 27 May 2019 15:55:41 +0100 Subject: [PATCH 1/3] Fix some comment and empty lines in settings --- {{cookiecutter.project_slug}}/config/settings/production.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index d9771e59..476e0dff 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -66,9 +66,9 @@ SECURE_CONTENT_TYPE_NOSNIFF = env.bool( "DJANGO_SECURE_CONTENT_TYPE_NOSNIFF", default=True ) +{% if cookiecutter.cloud_provider != 'None' -%} # STORAGES # ------------------------------------------------------------------------------ -{% if cookiecutter.cloud_provider != 'None' -%} # https://django-storages.readthedocs.io/en/latest/#installation INSTALLED_APPS += ["storages"] # noqa F405 {%- endif -%} @@ -101,10 +101,10 @@ GS_DEFAULT_ACL = "publicRead" # ------------------------ {% if cookiecutter.use_whitenoise == 'y' -%} STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" -{%- elif cookiecutter.cloud_provider == 'AWS' %} +{% elif cookiecutter.cloud_provider == 'AWS' -%} STATICFILES_STORAGE = "config.settings.production.StaticRootS3Boto3Storage" STATIC_URL = f"https://{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com/static/" -{%- elif cookiecutter.cloud_provider == 'GCE' %} +{% elif cookiecutter.cloud_provider == 'GCE' -%} STATIC_URL = "https://storage.googleapis.com/{}/static/".format(GS_BUCKET_NAME) {%- endif %} From 881a6fd681abe83dd2a6b4f83782312e7e8ee96f Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 27 May 2019 15:58:56 +0100 Subject: [PATCH 2/3] Change GCP settings to f-strings --- {{cookiecutter.project_slug}}/config/settings/production.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index 476e0dff..6fd0eac9 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -105,7 +105,7 @@ STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" STATICFILES_STORAGE = "config.settings.production.StaticRootS3Boto3Storage" STATIC_URL = f"https://{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com/static/" {% elif cookiecutter.cloud_provider == 'GCE' -%} -STATIC_URL = "https://storage.googleapis.com/{}/static/".format(GS_BUCKET_NAME) +STATIC_URL = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/static/" {%- endif %} # MEDIA @@ -130,8 +130,8 @@ class MediaRootS3Boto3Storage(S3Boto3Storage): DEFAULT_FILE_STORAGE = "config.settings.production.MediaRootS3Boto3Storage" MEDIA_URL = f"https://{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com/media/" {%- elif cookiecutter.cloud_provider == 'GCE' %} -MEDIA_URL = "https://storage.googleapis.com/{}/media/".format(GS_BUCKET_NAME) -MEDIA_ROOT = "https://storage.googleapis.com/{}/media/".format(GS_BUCKET_NAME) +MEDIA_URL = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/media/" +MEDIA_ROOT = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/media/" {%- endif %} # TEMPLATES From b56071f516e9201d957dd9bc5691af339d15fbde Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 27 May 2019 16:33:07 +0100 Subject: [PATCH 3/3] Fix comments and empty lines in prod settings --- {{cookiecutter.project_slug}}/config/settings/production.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index 6fd0eac9..1dbd2880 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -95,10 +95,12 @@ AWS_S3_REGION_NAME = env("DJANGO_AWS_S3_REGION_NAME", default=None) DEFAULT_FILE_STORAGE = "storages.backends.gcloud.GoogleCloudStorage" GS_BUCKET_NAME = env("DJANGO_GCE_STORAGE_BUCKET_NAME") GS_DEFAULT_ACL = "publicRead" -{% endif %} +{% endif -%} +{% if cookiecutter.cloud_provider != 'None' or cookiecutter.use_whitenoise == 'y' -%} # STATIC # ------------------------ +{% endif -%} {% if cookiecutter.use_whitenoise == 'y' -%} STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" {% elif cookiecutter.cloud_provider == 'AWS' -%} @@ -106,7 +108,7 @@ STATICFILES_STORAGE = "config.settings.production.StaticRootS3Boto3Storage" STATIC_URL = f"https://{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com/static/" {% elif cookiecutter.cloud_provider == 'GCE' -%} STATIC_URL = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/static/" -{%- endif %} +{% endif -%} # MEDIA # ------------------------------------------------------------------------------