Skip to content

Commit 36cc407

Browse files
authored
Merge pull request #977 from hunzlahmalik/master
feat: Upgrading storages with new dict Django52
2 parents c7b87e6 + 2d0d881 commit 36cc407

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

xqueue/production.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ def get_env_setting(setting):
1919
raise ImproperlyConfigured(error_msg)
2020

2121

22+
STORAGES = {
23+
"default": {
24+
"BACKEND": "django.core.files.storage.FileSystemStorage",
25+
},
26+
"staticfiles": {
27+
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
28+
},
29+
}
30+
2231
# Keep track of the names of settings that represent dicts. Instead of overriding the values in settings.py,
2332
# the values read from disk should UPDATE the pre-configured dicts.
2433
DICT_UPDATE_KEYS = ()
@@ -35,6 +44,17 @@ def get_env_setting(setting):
3544
if value:
3645
vars()[key].update(value)
3746

47+
# Fallback for DEFAULT_FILE_STORAGE and STATICFILES_STORAGE settings.
48+
# If these keys are present in the YAML config, use them to override the default storage backends.
49+
default_backend = config_from_yaml.pop('DEFAULT_FILE_STORAGE', None)
50+
static_backend = config_from_yaml.pop('STATICFILES_STORAGE', None)
51+
52+
if default_backend:
53+
STORAGES['default']['BACKEND'] = default_backend
54+
55+
if static_backend:
56+
STORAGES['staticfiles']['BACKEND'] = static_backend
57+
3858
vars().update(config_from_yaml)
3959

4060
LOGGING = get_logger_config(LOG_DIR,

0 commit comments

Comments
 (0)