mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #26029 -- Allowed configuring custom file storage backends.
This commit is contained in:
parent
d02a9f0cee
commit
1ec3f0961f
12 changed files with 209 additions and 11 deletions
|
@ -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`
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
-----
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue