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/ref | |
| parent | d02a9f0cee84e3d23f676bdf2ab6aadbf4a5bfe8 (diff) | |
Fixed #26029 -- Allowed configuring custom file storage backends.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/contrib/staticfiles.txt | 1 | ||||
| -rw-r--r-- | docs/ref/files/storage.txt | 6 | ||||
| -rw-r--r-- | docs/ref/settings.txt | 38 |
3 files changed, 45 insertions, 0 deletions
diff --git a/docs/ref/contrib/staticfiles.txt b/docs/ref/contrib/staticfiles.txt index 7ca3584c33..08fc23bdb1 100644 --- a/docs/ref/contrib/staticfiles.txt +++ b/docs/ref/contrib/staticfiles.txt @@ -23,6 +23,7 @@ Settings See :ref:`staticfiles settings <settings-staticfiles>` for details on the following settings: +* :setting:`STORAGES` * :setting:`STATIC_ROOT` * :setting:`STATIC_URL` * :setting:`STATICFILES_DIRS` diff --git a/docs/ref/files/storage.txt b/docs/ref/files/storage.txt index fa79a4f91a..d5daccf834 100644 --- a/docs/ref/files/storage.txt +++ b/docs/ref/files/storage.txt @@ -9,6 +9,12 @@ Getting the default storage class Django provides convenient ways to access the default storage class: +.. data:: storages + + .. versionadded:: 4.2 + + Storage instances as defined by :setting:`STORAGES`. + .. class:: DefaultStorage :class:`~django.core.files.storage.DefaultStorage` provides diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt index b1a8e2444d..d1b638f4b6 100644 --- a/docs/ref/settings.txt +++ b/docs/ref/settings.txt @@ -2606,6 +2606,43 @@ Silenced checks will not be output to the console. See also the :doc:`/ref/checks` documentation. +.. setting:: STORAGES + +``STORAGES`` +------------ + +.. versionadded:: 4.2 + +Default:: + + {} + +A dictionary containing the settings for all storages to be used with Django. +It is a nested dictionary whose contents map a storage alias to a dictionary +containing the options for an individual storage. + +Storages can have any alias you choose. + +The following is an example ``settings.py`` snippet defining a custom file +storage called ``example``:: + + STORAGES = { + # ... + "example": { + "BACKEND": "django.core.files.storage.FileSystemStorage", + "OPTIONS": { + "location": "/example", + "base_url": "/example/", + }, + }, + } + +``OPTIONS`` are passed to the ``BACKEND`` on initialization in ``**kwargs``. + +A ready-to-use instance of the storage backends can be retrieved from +:data:`django.core.files.storage.storages`. Use a key corresponding to the +backend definition in :setting:`STORAGES`. + .. setting:: TEMPLATES ``TEMPLATES`` @@ -3663,6 +3700,7 @@ File uploads * :setting:`FILE_UPLOAD_TEMP_DIR` * :setting:`MEDIA_ROOT` * :setting:`MEDIA_URL` +* :setting:`STORAGES` Forms ----- |
