summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJarosław Wygoda <jaroslaw@wygoda.me>2022-09-11 17:33:47 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-01-12 09:58:36 +0100
commit32940d390a00a30a6409282d314d617667892841 (patch)
tree3912c57c1b553833a8a798d92a33147fb87b3f0b /docs
parent1ec3f0961fedbe01f174b78ef2805a9d4f3844b1 (diff)
Refs #26029 -- Deprecated DEFAULT_FILE_STORAGE and STATICFILES_STORAGE settings.
Diffstat (limited to 'docs')
-rw-r--r--docs/howto/static-files/deployment.txt17
-rw-r--r--docs/howto/static-files/index.txt3
-rw-r--r--docs/internals/deprecation.txt6
-rw-r--r--docs/ref/contrib/staticfiles.txt30
-rw-r--r--docs/ref/files/storage.txt21
-rw-r--r--docs/ref/settings.txt37
-rw-r--r--docs/ref/templates/builtins.txt2
-rw-r--r--docs/releases/4.2.txt15
-rw-r--r--docs/topics/files.txt7
-rw-r--r--docs/topics/testing/tools.txt19
10 files changed, 111 insertions, 46 deletions
diff --git a/docs/howto/static-files/deployment.txt b/docs/howto/static-files/deployment.txt
index bd35d13025..67ecf59a71 100644
--- a/docs/howto/static-files/deployment.txt
+++ b/docs/howto/static-files/deployment.txt
@@ -15,8 +15,8 @@ Serving static files in production
The basic outline of putting static files into production consists of two
steps: run the :djadmin:`collectstatic` command when static files change, then
arrange for the collected static files directory (:setting:`STATIC_ROOT`) to be
-moved to the static file server and served. Depending on
-:setting:`STATICFILES_STORAGE`, files may need to be moved to a new location
+moved to the static file server and served. Depending the ``staticfiles``
+:setting:`STORAGES` alias, files may need to be moved to a new location
manually or the :func:`post_process
<django.contrib.staticfiles.storage.StaticFilesStorage.post_process>` method of
the ``Storage`` class might take care of that.
@@ -85,17 +85,20 @@ There's any number of ways you might do this, but if the provider has an API,
you can use a :doc:`custom file storage backend </howto/custom-file-storage>`
to integrate the CDN with your Django project. If you've written or are using a
3rd party custom storage backend, you can tell :djadmin:`collectstatic` to use
-it by setting :setting:`STATICFILES_STORAGE` to the storage engine.
+it by setting ``staticfiles`` in :setting:`STORAGES`.
For example, if you've written an S3 storage backend in
``myproject.storage.S3Storage`` you could use it with::
- STATICFILES_STORAGE = 'myproject.storage.S3Storage'
+ STORAGES = {
+ # ...
+ "staticfiles": {"BACKEND": "myproject.storage.S3Storage"}
+ }
Once that's done, all you have to do is run :djadmin:`collectstatic` and your
static files would be pushed through your storage package up to S3. If you
later needed to switch to a different storage provider, you may only have to
-change your :setting:`STATICFILES_STORAGE` setting.
+change ``staticfiles`` in the :setting:`STORAGES` setting.
For details on how you'd write one of these backends, see
:doc:`/howto/custom-file-storage`. There are 3rd party apps available that
@@ -103,6 +106,10 @@ provide storage backends for many common file storage APIs. A good starting
point is the `overview at djangopackages.org
<https://djangopackages.org/grids/g/storage-backends/>`_.
+.. versionchanged:: 4.2
+
+ The :setting:`STORAGES` setting was added.
+
Learn more
==========
diff --git a/docs/howto/static-files/index.txt b/docs/howto/static-files/index.txt
index 20d21eb07c..def58c5ed1 100644
--- a/docs/howto/static-files/index.txt
+++ b/docs/howto/static-files/index.txt
@@ -19,7 +19,8 @@ Configuring static files
STATIC_URL = 'static/'
#. In your templates, use the :ttag:`static` template tag to build the URL for
- the given relative path using the configured :setting:`STATICFILES_STORAGE`.
+ the given relative path using the configured ``staticfiles``
+ :setting:`STORAGES` alias.
.. _staticfiles-in-templates:
diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt
index 1908549e8c..86326c3b4f 100644
--- a/docs/internals/deprecation.txt
+++ b/docs/internals/deprecation.txt
@@ -45,6 +45,12 @@ details on these changes.
* Support for passing positional arguments to ``Signer`` and
``TimestampSigner`` will be removed.
+* The ``DEFAULT_FILE_STORAGE`` and ``STATICFILES_STORAGE`` settings will be
+ removed.
+
+* The ``django.core.files.storage.get_storage_class()`` function will be
+ removed.
+
.. _deprecation-removed-in-5.0:
5.0
diff --git a/docs/ref/contrib/staticfiles.txt b/docs/ref/contrib/staticfiles.txt
index 08fc23bdb1..a72e2ae286 100644
--- a/docs/ref/contrib/staticfiles.txt
+++ b/docs/ref/contrib/staticfiles.txt
@@ -60,11 +60,12 @@ specified by the :setting:`INSTALLED_APPS` setting.
The :djadmin:`collectstatic` management command calls the
:meth:`~django.contrib.staticfiles.storage.StaticFilesStorage.post_process`
-method of the :setting:`STATICFILES_STORAGE` after each run and passes
-a list of paths that have been found by the management command. It also
-receives all command line options of :djadmin:`collectstatic`. This is used
-by the :class:`~django.contrib.staticfiles.storage.ManifestStaticFilesStorage`
-by default.
+method of the ``staticfiles`` storage backend from :setting:`STORAGES` after
+each run and passes a list of paths that have been found by the management
+command. It also receives all command line options of :djadmin:`collectstatic`.
+This is used by the
+:class:`~django.contrib.staticfiles.storage.ManifestStaticFilesStorage` by
+default.
By default, collected files receive permissions from
:setting:`FILE_UPLOAD_PERMISSIONS` and collected directories receive permissions
@@ -82,7 +83,7 @@ respectively. For example::
kwargs['directory_permissions_mode'] = 0o760
super().__init__(*args, **kwargs)
-Then set the :setting:`STATICFILES_STORAGE` setting to
+Then set the ``staticfiles`` storage backend in :setting:`STORAGES` setting to
``'path.to.MyStaticFilesStorage'``.
Some commonly used options are:
@@ -113,7 +114,8 @@ Some commonly used options are:
Don't call the
:meth:`~django.contrib.staticfiles.storage.StaticFilesStorage.post_process`
- method of the configured :setting:`STATICFILES_STORAGE` storage backend.
+ method of the configured ``staticfiles`` storage backend from
+ :setting:`STORAGES`.
.. django-admin-option:: --no-default-ignore
@@ -360,7 +362,7 @@ attribute. It defaults to 5.
To enable the ``ManifestStaticFilesStorage`` you have to make sure the
following requirements are met:
-* the :setting:`STATICFILES_STORAGE` setting is set to
+* the ``staticfiles`` storage backend in :setting:`STORAGES` setting is set to
``'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'``
* the :setting:`DEBUG` setting is set to ``False``
* you've collected all your static files by using the
@@ -381,9 +383,9 @@ If a file isn't found in the ``staticfiles.json`` manifest at runtime, a
Due to the requirement of running :djadmin:`collectstatic`, this storage
typically shouldn't be used when running tests as ``collectstatic`` isn't run
-as part of the normal test setup. During testing, ensure that the
-:setting:`STATICFILES_STORAGE` setting is set to something else like
-``'django.contrib.staticfiles.storage.StaticFilesStorage'`` (the default).
+as part of the normal test setup. During testing, ensure that ``staticfiles``
+storage backend in the :setting:`STORAGES` setting is set to something else
+like ``'django.contrib.staticfiles.storage.StaticFilesStorage'`` (the default).
.. method:: storage.ManifestStaticFilesStorage.file_hash(name, content=None)
@@ -434,7 +436,8 @@ files:
- The builtin template tag :ttag:`static` which takes a path and urljoins it
with the static prefix :setting:`STATIC_URL`. If
``django.contrib.staticfiles`` is installed, the tag uses the ``url()``
- method of the :setting:`STATICFILES_STORAGE` instead.
+ method of the ``staticfiles`` storage backend from :setting:`STORAGES`
+ instead.
- The builtin template tag :ttag:`get_static_prefix` which populates a
template variable with the static prefix :setting:`STATIC_URL` to be
@@ -443,6 +446,9 @@ files:
- The similar template tag :ttag:`get_media_prefix` which works like
:ttag:`get_static_prefix` but uses :setting:`MEDIA_URL`.
+- The ``staticfiles`` key in :data:`django.core.files.storage.storages`
+ contains a ready-to-use instance of the staticfiles storage backend.
+
.. _staticfiles-development-view:
Static file development view
diff --git a/docs/ref/files/storage.txt b/docs/ref/files/storage.txt
index d5daccf834..47a5788574 100644
--- a/docs/ref/files/storage.txt
+++ b/docs/ref/files/storage.txt
@@ -18,9 +18,9 @@ Django provides convenient ways to access the default storage class:
.. class:: DefaultStorage
:class:`~django.core.files.storage.DefaultStorage` provides
- lazy access to the current default storage system as defined by
- :setting:`DEFAULT_FILE_STORAGE`. :class:`DefaultStorage` uses
- :func:`~django.core.files.storage.get_storage_class` internally.
+ lazy access to the default storage system as defined by ``default`` key in
+ :setting:`STORAGES`. :class:`DefaultStorage` uses
+ :data:`~django.core.files.storage.storages` internally.
.. data:: default_storage
@@ -32,11 +32,16 @@ Django provides convenient ways to access the default storage class:
Returns a class or module which implements the storage API.
When called without the ``import_path`` parameter ``get_storage_class``
- will return the current default storage system as defined by
- :setting:`DEFAULT_FILE_STORAGE`. If ``import_path`` is provided,
- ``get_storage_class`` will attempt to import the class or module from the
- given path and will return it if successful. An exception will be
- raised if the import is unsuccessful.
+ will return the default storage system as defined by ``default`` key in
+ :setting:`STORAGES`. If ``import_path`` is provided, ``get_storage_class``
+ will attempt to import the class or module from the given path and will
+ return it if successful. An exception will be raised if the import is
+ unsuccessful.
+
+ .. deprecated:: 4.2
+
+ The ``get_storage_class()`` function is deprecated. Use
+ :data:`storages` instead
The ``FileSystemStorage`` class
===============================
diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt
index d1b638f4b6..aa8606a08b 100644
--- a/docs/ref/settings.txt
+++ b/docs/ref/settings.txt
@@ -1356,6 +1356,12 @@ Default: ``'``:class:`django.core.files.storage.FileSystemStorage`\ ``'``
Default file storage class to be used for any file-related operations that don't
specify a particular storage system. See :doc:`/topics/files`.
+.. deprecated:: 4.2
+
+ This setting is deprecated. Starting with Django 4.2, default file storage
+ engine can be configured with the :setting:`STORAGES` setting under the
+ ``default`` key.
+
.. setting:: DEFAULT_FROM_EMAIL
``DEFAULT_FROM_EMAIL``
@@ -2615,13 +2621,28 @@ See also the :doc:`/ref/checks` documentation.
Default::
- {}
+ {
+ "default": {
+ "BACKEND": "django.core.files.storage.FileSystemStorage",
+ },
+ "staticfiles": {
+ "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
+ },
+ }
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.
+Storages can have any alias you choose. However, there are two aliases with
+special significance:
+
+* ``default`` for :doc:`managing files </topics/files>`.
+ ``'``:class:`django.core.files.storage.FileSystemStorage`\ ``'`` is the
+ default storage engine.
+* ``staticfiles`` for :doc:`managing static files </ref/contrib/staticfiles>`.
+ ``'``:class:`django.contrib.staticfiles.storage.StaticFilesStorage`\ ``'`` is
+ the default storage engine.
The following is an example ``settings.py`` snippet defining a custom file
storage called ``example``::
@@ -3598,10 +3619,16 @@ The file storage engine to use when collecting static files with the
:djadmin:`collectstatic` management command.
A ready-to-use instance of the storage backend defined in this setting
-can be found at ``django.contrib.staticfiles.storage.staticfiles_storage``.
+can be found under ``staticfiles`` key in ``django.core.files.storage.storages``.
For an example, see :ref:`staticfiles-from-cdn`.
+.. deprecated:: 4.2
+
+ This setting is deprecated. Starting with Django 4.2, static files storage
+ engine can be configured with the :setting:`STORAGES` setting under the
+ ``staticfiles`` key.
+
.. setting:: STATICFILES_FINDERS
``STATICFILES_FINDERS``
@@ -3627,8 +3654,8 @@ used.
One finder is disabled by default:
``django.contrib.staticfiles.finders.DefaultStorageFinder``. If added to
your :setting:`STATICFILES_FINDERS` setting, it will look for static files in
-the default file storage as defined by the :setting:`DEFAULT_FILE_STORAGE`
-setting.
+the default file storage as defined by the ``default`` key in the
+:setting:`STORAGES` setting.
.. note::
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
index 13a8694ad6..5804f455bd 100644
--- a/docs/ref/templates/builtins.txt
+++ b/docs/ref/templates/builtins.txt
@@ -2629,7 +2629,7 @@ A set of Django template filters useful for adding a "human touch" to data. See
To link to static files that are saved in :setting:`STATIC_ROOT` Django ships
with a :ttag:`static` template tag. If the :mod:`django.contrib.staticfiles`
app is installed, the tag will serve files using ``url()`` method of the
-storage specified by :setting:`STATICFILES_STORAGE`. For example::
+storage specified by ``staticfiles`` in :setting:`STORAGES`. For example::
{% load static %}
<img src="{% static 'images/hi.jpg' %}" alt="Hi!">
diff --git a/docs/releases/4.2.txt b/docs/releases/4.2.txt
index ecc9a06a87..c3b939bf8b 100644
--- a/docs/releases/4.2.txt
+++ b/docs/releases/4.2.txt
@@ -95,7 +95,12 @@ Custom file storages
--------------------
The new :setting:`STORAGES` setting allows configuring multiple custom file
-storage backends.
+storage backends. It also controls storage engines for managing
+:doc:`files </topics/files>` (the ``"defaut"`` key) and :doc:`static files
+</ref/contrib/staticfiles>` (the ``"staticfiles"`` key).
+
+The old ``DEFAULT_FILE_STORAGE`` and ``STATICFILES_STORAGE`` settings are
+deprecated as of this release.
Minor features
--------------
@@ -674,3 +679,11 @@ Miscellaneous
* Passing positional arguments to ``Signer`` and ``TimestampSigner`` is
deprecated in favor of keyword-only arguments.
+
+* The ``DEFAULT_FILE_STORAGE`` setting is deprecated in favor of
+ ``STORAGES["default"]``.
+
+* The ``STATICFILES_STORAGE`` setting is deprecated in favor of
+ ``STORAGES["staticfiles"]``.
+
+* The ``django.core.files.storage.get_storage_class()`` function is deprecated.
diff --git a/docs/topics/files.txt b/docs/topics/files.txt
index eb4e655cfa..ad0dcffdd1 100644
--- a/docs/topics/files.txt
+++ b/docs/topics/files.txt
@@ -156,9 +156,10 @@ Behind the scenes, Django delegates decisions about how and where to store files
to a file storage system. This is the object that actually understands things
like file systems, opening and reading files, etc.
-Django's default file storage is given by the :setting:`DEFAULT_FILE_STORAGE`
-setting; if you don't explicitly provide a storage system, this is the one that
-will be used.
+Django's default file storage is
+``'``:class:`django.core.files.storage.FileSystemStorage`\ ``'``. If you don't
+explicitly provide a storage system in the ``default`` key of the
+:setting:`STORAGES` setting, this is the one that will be used.
See below for details of the built-in default file storage system, and see
:doc:`/howto/custom-file-storage` for information on writing your own file
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt
index 524fc85584..1ecc97a2a9 100644
--- a/docs/topics/testing/tools.txt
+++ b/docs/topics/testing/tools.txt
@@ -1441,16 +1441,15 @@ 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
-STATIC_ROOT, STATIC_URL, STORAGES Storages configuration
-================================= ========================
+============================================================================ ========================
+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
+DEFAULT_FILE_STORAGE, STATICFILES_STORAGE, STATIC_ROOT, STATIC_URL, STORAGES Storages configuration
+============================================================================ ========================
Isolating apps
--------------