Skip to content

Commit b4d9cf3

Browse files
RealOrangeOnelaymonage
authored andcommitted
Use Django 4.2+ syntax for storage
1 parent f85f074 commit b4d9cf3

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

bakerydemo/base/management/commands/reset_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def handle(self, **options):
1717
)
1818

1919
# 1. (optional) Remove all objects from S3
20-
if "s3" in settings.DEFAULT_FILE_STORAGE:
20+
if "s3" in default_storage.__class__.__name__.lower():
2121
self.stdout.write("Removing files from S3")
2222
default_storage.bucket.objects.all().delete()
2323
else:

bakerydemo/settings/base.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,15 @@
182182
MEDIA_ROOT = os.path.join(PROJECT_DIR, "media")
183183
MEDIA_URL = "/media/"
184184

185+
STORAGES = {
186+
"default": {
187+
"BACKEND": "django.core.files.storage.FileSystemStorage",
188+
},
189+
"staticfiles": {
190+
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
191+
},
192+
}
193+
185194
# Override in local settings or replace with your own key. Please don't use our demo key in production!
186195
GOOGLE_MAP_API_KEY = "AIzaSyD31CT9P9KxvNUJOwDq2kcFEIG8ADgaFgw"
187196

bakerydemo/settings/production.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,15 @@
141141
# https://warehouse.python.org/project/whitenoise/
142142

143143
MIDDLEWARE.append("whitenoise.middleware.WhiteNoiseMiddleware")
144-
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
144+
STORAGES["staticfiles"][
145+
"BACKEND"
146+
] = "whitenoise.storage.CompressedManifestStaticFilesStorage"
145147

146148
if "AWS_STORAGE_BUCKET_NAME" in os.environ:
147149
AWS_STORAGE_BUCKET_NAME = os.getenv("AWS_STORAGE_BUCKET_NAME")
148150
AWS_QUERYSTRING_AUTH = False
149151
INSTALLED_APPS.append("storages")
150-
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
152+
STORAGES["default"]["BACKEND"] = "storages.backends.s3boto3.S3Boto3Storage"
151153
AWS_S3_FILE_OVERWRITE = False
152154
AWS_DEFAULT_ACL = "private"
153155
if "AWS_S3_CUSTOM_DOMAIN" in os.environ:
@@ -162,7 +164,7 @@
162164
GS_AUTO_CREATE_BUCKET = True
163165

164166
INSTALLED_APPS.append("storages")
165-
DEFAULT_FILE_STORAGE = "storages.backends.gcloud.GoogleCloudStorage"
167+
STORAGES["default"]["BACKEND"] = "storages.backends.gcloud.GoogleCloudStorage"
166168

167169
LOGGING = {
168170
"version": 1,

0 commit comments

Comments
 (0)