Skip to content

Commit 813bbb8

Browse files
committed
feat: Upgrading storages with new dict Django52
1 parent a806a56 commit 813bbb8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

xqueue/production.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ def get_env_setting(setting):
1818
error_msg = "Set the %s env variable" % setting
1919
raise ImproperlyConfigured(error_msg)
2020

21+
STORAGES = {
22+
"default": {
23+
"BACKEND": "django.core.files.storage.FileSystemStorage",
24+
},
25+
"staticfiles": {
26+
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
27+
},
28+
}
2129

2230
# Keep track of the names of settings that represent dicts. Instead of overriding the values in settings.py,
2331
# the values read from disk should UPDATE the pre-configured dicts.
@@ -35,8 +43,19 @@ def get_env_setting(setting):
3543
if value:
3644
vars()[key].update(value)
3745

46+
# Fallback for DEFAULT_FILE_STORAGE and STATICFILES_STORAGE settings.
47+
# If these keys are present in the YAML config, use them to override the default storage backends.
48+
default_backend = config_from_yaml.pop('DEFAULT_FILE_STORAGE', None)
49+
static_backend = config_from_yaml.pop('STATICFILES_STORAGE', None)
50+
3851
vars().update(config_from_yaml)
3952

53+
if default_backend:
54+
STORAGES['default']['BACKEND'] = default_backend
55+
56+
if static_backend:
57+
STORAGES['staticfiles']['BACKEND'] = static_backend
58+
4059
LOGGING = get_logger_config(LOG_DIR,
4160
logging_env=LOGGING_ENV,
4261
syslog_addr=(SYSLOG_SERVER, 514),

0 commit comments

Comments
 (0)