Skip to content

Commit 2e9ec31

Browse files
Update settings.py
1 parent 98b03c8 commit 2e9ec31

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

superapp/settings.py

+42-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
# Apps
4646
######################################################################
4747
INSTALLED_APPS = [
48+
"storages",
4849
"django_superapp",
4950
"django.contrib.admin",
5051
"django.contrib.auth",
@@ -210,6 +211,46 @@
210211
######################################################################
211212
X_FRAME_OPTIONS = "SAMEORIGIN"
212213

214+
######################################################################
215+
# STORAGE
216+
######################################################################
217+
218+
if environ.get("AWS_ACCESS_KEY_ID"):
219+
AWS_ACCESS_KEY_ID = environ.get("AWS_ACCESS_KEY_ID")
220+
AWS_SECRET_ACCESS_KEY = environ.get("AWS_SECRET_ACCESS_KEY")
221+
AWS_STORAGE_BUCKET_NAME = environ.get("AWS_STORAGE_BUCKET_NAME")
222+
AWS_ENDPOINT_URL = environ.get("AWS_ENDPOINT_URL")
223+
AWS_S3_SIGNATURE_VERSION = environ.get("AWS_S3_SIGNATURE_VERSION")
224+
AWS_S3_ADDRESSING_STYLE = environ.get("AWS_S3_ADDRESSING_STYLE")
225+
AWS_S3_CUSTOM_DOMAIN = environ.get("AWS_S3_CUSTOM_DOMAIN")
226+
STORAGES = {
227+
"default": {
228+
"BACKEND": "storages.backends.s3.S3Storage",
229+
"OPTIONS": {
230+
},
231+
},
232+
"staticfiles": {
233+
"BACKEND": "storages.backends.s3.S3Storage",
234+
"OPTIONS": {
235+
"querystring_auth": False,
236+
"default_acl": "public-read",
237+
},
238+
} if not DEBUG else {
239+
"BACKEND": "whitenoise.storage.CompressedStaticFilesStorage",
240+
"OPTIONS": {},
241+
},
242+
}
243+
else:
244+
STORAGES = {
245+
"default": {
246+
"BACKEND": "whitenoise.storage.CompressedStaticFilesStorage",
247+
"OPTIONS": {},
248+
},
249+
"staticfiles": {
250+
"BACKEND": "whitenoise.storage.CompressedStaticFilesStorage",
251+
"OPTIONS": {},
252+
},
253+
}
213254
######################################################################
214255
# SUPERAPP dynamic settings and urls
215256
######################################################################
@@ -219,4 +260,4 @@
219260
extend_superapp_settings(
220261
main_settings=globals(),
221262
superapp_apps=superapp_apps
222-
)
263+
)

0 commit comments

Comments
 (0)