Update checks.py (#10462)

Prevent "RemovedInDjango51Warning: The DEFAULT_FILE_STORAGE setting is deprecated. Use STORAGES instead."
pull/11120/head
phijma-leukeleu 2023-05-22 16:03:08 +02:00 zatwierdzone przez Matt Westcott
rodzic 1c76db228c
commit 1fd4b86022
4 zmienionych plików z 13 dodań i 2 usunięć

Wyświetl plik

@ -4,6 +4,7 @@ Changelog
5.3 (xx.xx.xxxx) - IN DEVELOPMENT
~~~~~~~~~~~~~~~~
* Fix: Update system check for overwriting storage backends to recognise the `STORAGES` setting introduced in Django 4.2 (phijma-leukeleu)
* Maintenance: Update BeautifulSoup upper bound to 4.12.x (scott-8)

Wyświetl plik

@ -754,6 +754,7 @@
* Meghana Reddy
* Chinedu Ihedioha
* scott-8
* phijma-leukeleu
## Translators

Wyświetl plik

@ -18,7 +18,7 @@ depth: 1
### Bug fixes
* ...
* Update system check for overwriting storage backends to recognise the `STORAGES` setting introduced in Django 4.2 (phijma-leukeleu)
### Documentation

Wyświetl plik

@ -188,8 +188,17 @@ def wagtail_admin_base_url_check(app_configs, **kwargs):
@register("file_overwrite")
def file_overwrite_check(app_configs, **kwargs):
from django.conf import settings
from django import VERSION as DJANGO_VERSION
file_storage = getattr(settings, "DEFAULT_FILE_STORAGE", None)
if DJANGO_VERSION >= (5, 1):
file_storage = getattr(settings, "STORAGES")["default"]["BACKEND"]
elif DJANGO_VERSION >= (4, 2):
try:
file_storage = getattr(settings, "STORAGES")["default"]["BACKEND"]
except AttributeError:
file_storage = getattr(settings, "DEFAULT_FILE_STORAGE", None)
else:
file_storage = getattr(settings, "DEFAULT_FILE_STORAGE", None)
errors = []