|
206 | 206 | STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles_collected') |
207 | 207 |
|
208 | 208 |
|
| 209 | +# AWS S3 storage configuration |
| 210 | +AWS_STORAGE_BUCKET_NAME = os.environ.get('DEFAULT_STORAGE_BUCKET', '') |
| 211 | +AWS_ACCESS_KEY_ID = os.environ.get('DEFAULT_STORAGE_ACCESS_KEY_ID', '') |
| 212 | +AWS_SECRET_ACCESS_KEY = os.environ.get('DEFAULT_STORAGE_SECRET_ACCESS_KEY', '') |
| 213 | +AWS_S3_CUSTOM_DOMAIN = os.environ.get('DEFAULT_STORAGE_CUSTOM_DOMAIN', '') |
| 214 | +AWS_S3_REGION_NAME = os.environ.get('DEFAULT_STORAGE_REGION', '') |
| 215 | +AWS_S3_OBJECT_PARAMETERS = { |
| 216 | + 'ACL': 'public-read', |
| 217 | + 'CacheControl': 'max-age=86400', |
| 218 | +} |
| 219 | +AWS_S3_FILE_OVERWRITE = False |
| 220 | + |
| 221 | + |
209 | 222 | # Default storage settings, with the staticfiles storage updated. |
210 | 223 | # See https://docs.djangoproject.com/en/5.0/ref/settings/#std-setting-STORAGES |
| 224 | +STORAGE_BACKEND = "django.core.files.storage.FileSystemStorage" |
| 225 | + |
| 226 | +if AWS_SECRET_ACCESS_KEY: |
| 227 | + STORAGE_BACKEND = "storages.backends.s3boto3.S3Boto3Storage" |
211 | 228 |
|
212 | 229 | STORAGES = { |
213 | 230 | "default": { |
214 | | - "BACKEND": "storages.backends.s3boto3.S3Boto3Storage", |
| 231 | + "BACKEND": STORAGE_BACKEND, |
215 | 232 | }, |
| 233 | + # ManifestStaticFilesStorage is recommended in production, to prevent |
| 234 | + # outdated JavaScript / CSS assets being served from cache |
| 235 | + # See https://docs.djangoproject.com/en/5.0/ref/contrib/staticfiles/#manifeststaticfilesstorage |
216 | 236 | "staticfiles": { |
217 | | - "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage", |
| 237 | + "BACKEND": "django.contrib.staticfiles.storage.ManifestStaticFilesStorage", |
218 | 238 | }, |
219 | 239 | } |
220 | 240 |
|
|
242 | 262 |
|
243 | 263 | CMS_CONFIRM_VERSION4 = True |
244 | 264 | DJANGOCMS_VERSIONING_ALLOW_DELETING_VERSIONS = True |
245 | | - |
246 | | - |
247 | | -# AWS S3 storage configuration |
248 | | -AWS_ACCESS_KEY_ID = os.environ.get('DEFAULT_STORAGE_ACCESS_KEY_ID', '') |
249 | | -AWS_SECRET_ACCESS_KEY = os.environ.get('DEFAULT_STORAGE_SECRET_ACCESS_KEY', '') |
250 | | -AWS_S3_REGION_NAME = os.environ.get('DEFAULT_STORAGE_REGION', '') |
251 | | -AWS_STORAGE_BUCKET_NAME=os.environ.get('DEFAULT_STORAGE_BUCKET', '') |
252 | | -AWS_S3_CUSTOM_DOMAIN = os.environ.get('DEFAULT_STORAGE_CUSTOM_DOMAIN', '') |
253 | | -AWS_S3_OBJECT_PARAMETERS = { |
254 | | - 'ACL': 'public-read', |
255 | | - 'CacheControl': 'max-age=86400', |
256 | | -} |
|
0 commit comments