diff options
| author | Jarosław Wygoda <jaroslaw@wygoda.me> | 2023-01-11 10:48:57 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-01-12 06:20:57 +0100 |
| commit | 1ec3f0961fedbe01f174b78ef2805a9d4f3844b1 (patch) | |
| tree | 58c346b0abf71be4cee2e8d07ed1ddc4be744740 /docs/topics | |
| parent | d02a9f0cee84e3d23f676bdf2ab6aadbf4a5bfe8 (diff) | |
| download | django-1ec3f0961fedbe01f174b78ef2805a9d4f3844b1.tar.gz | |
Fixed #26029 -- Allowed configuring custom file storage backends.
Diffstat (limited to 'docs/topics')
| -rw-r--r-- | docs/topics/files.txt | 12 | ||||
| -rw-r--r-- | docs/topics/testing/tools.txt | 19 |
2 files changed, 22 insertions, 9 deletions
diff --git a/docs/topics/files.txt b/docs/topics/files.txt index 6f7f9c21e2..eb4e655cfa 100644 --- a/docs/topics/files.txt +++ b/docs/topics/files.txt @@ -239,3 +239,15 @@ For example:: class MyModel(models.Model): my_file = models.FileField(storage=select_storage) + +In order to set a storage defined in the :setting:`STORAGES` setting you can +use a lambda function:: + + from django.core.files.storage import storages + + class MyModel(models.Model): + upload = models.FileField(storage=lambda: storages["custom_storage"]) + +.. versionchanged:: 4.2 + + Support for ``storages`` was added. diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt index 139d66e64b..524fc85584 100644 --- a/docs/topics/testing/tools.txt +++ b/docs/topics/testing/tools.txt @@ -1441,15 +1441,16 @@ when settings are changed. Django itself uses this signal to reset various data: -================================ ======================== -Overridden settings Data reset -================================ ======================== -USE_TZ, TIME_ZONE Databases timezone -TEMPLATES Template engines -SERIALIZATION_MODULES Serializers cache -LOCALE_PATHS, LANGUAGE_CODE Default translation and loaded translations -MEDIA_ROOT, DEFAULT_FILE_STORAGE Default file storage -================================ ======================== +================================= ======================== +Overridden settings Data reset +================================= ======================== +USE_TZ, TIME_ZONE Databases timezone +TEMPLATES Template engines +SERIALIZATION_MODULES Serializers cache +LOCALE_PATHS, LANGUAGE_CODE Default translation and loaded translations +MEDIA_ROOT, DEFAULT_FILE_STORAGE Default file storage +STATIC_ROOT, STATIC_URL, STORAGES Storages configuration +================================= ======================== Isolating apps -------------- |
