fix: static and media files storages (#1482)

This commit is contained in:
pablohashescobar 2023-07-06 15:30:34 +05:30 committed by GitHub
parent 8443dfc9dd
commit 3a2f4d55d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 15 deletions

View File

@ -70,8 +70,12 @@ CORS_ALLOW_HEADERS = [
] ]
CORS_ALLOW_CREDENTIALS = True CORS_ALLOW_CREDENTIALS = True
# Simplified static file serving.
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" STORAGES = {
"staticfiles": {
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
},
}
if bool(os.environ.get("SENTRY_DSN", False)): if bool(os.environ.get("SENTRY_DSN", False)):
sentry_sdk.init( sentry_sdk.init(
@ -87,7 +91,7 @@ if bool(os.environ.get("SENTRY_DSN", False)):
if DOCKERIZED and USE_MINIO: if DOCKERIZED and USE_MINIO:
INSTALLED_APPS += ("storages",) INSTALLED_APPS += ("storages",)
STORAGES = {"default": {"BACKEND": "storages.backends.s3boto3.S3Boto3Storage"}} STORAGES["default"] = {"BACKEND": "storages.backends.s3boto3.S3Boto3Storage"}
# The AWS access key to use. # The AWS access key to use.
AWS_ACCESS_KEY_ID = os.environ.get("AWS_ACCESS_KEY_ID", "access-key") AWS_ACCESS_KEY_ID = os.environ.get("AWS_ACCESS_KEY_ID", "access-key")
# The AWS secret access key to use. # The AWS secret access key to use.
@ -188,7 +192,10 @@ else:
# extra characters appended. # extra characters appended.
AWS_S3_FILE_OVERWRITE = False AWS_S3_FILE_OVERWRITE = False
DEFAULT_FILE_STORAGE = "django_s3_storage.storage.S3Storage" STORAGES["default"] = {
"BACKEND": "django_s3_storage.storage.S3Storage",
}
# AWS Settings End # AWS Settings End
# Enable Connection Pooling (if desired) # Enable Connection Pooling (if desired)
@ -203,9 +210,6 @@ ALLOWED_HOSTS = [
] ]
# Simplified static file serving.
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
SESSION_COOKIE_SECURE = True SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True CSRF_COOKIE_SECURE = True

View File

@ -48,8 +48,12 @@ ALLOWED_HOSTS = ["*"]
# TODO: Make it FALSE and LIST DOMAINS IN FULL PROD. # TODO: Make it FALSE and LIST DOMAINS IN FULL PROD.
CORS_ALLOW_ALL_ORIGINS = True CORS_ALLOW_ALL_ORIGINS = True
# Simplified static file serving. STORAGES = {
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" "staticfiles": {
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
},
}
# Make true if running in a docker environment # Make true if running in a docker environment
DOCKERIZED = int(os.environ.get( DOCKERIZED = int(os.environ.get(
@ -151,7 +155,9 @@ AWS_S3_SIGNATURE_VERSION = None
AWS_S3_FILE_OVERWRITE = False AWS_S3_FILE_OVERWRITE = False
# AWS Settings End # AWS Settings End
STORAGES["default"] = {
"BACKEND": "django_s3_storage.storage.S3Storage",
}
# Enable Connection Pooling (if desired) # Enable Connection Pooling (if desired)
# DATABASES['default']['ENGINE'] = 'django_postgrespool' # DATABASES['default']['ENGINE'] = 'django_postgrespool'
@ -164,11 +170,6 @@ ALLOWED_HOSTS = [
"*", "*",
] ]
DEFAULT_FILE_STORAGE = "django_s3_storage.storage.S3Storage"
# Simplified static file serving.
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
SESSION_COOKIE_SECURE = True SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True CSRF_COOKIE_SECURE = True