Fixed #34530 -- Improved docs when customizing storage for FileField.

This commit is contained in:
Ran Benita 2023-05-02 21:32:24 +03:00 committed by GitHub
parent c61219a7ae
commit 506f93f0c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -261,13 +261,17 @@ For example::
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::
use :data:`~django.core.files.storage.storages`::
from django.core.files.storage import storages
def select_storage():
return storages["mystorage"]
class MyModel(models.Model):
upload = models.FileField(storage=lambda: storages["custom_storage"])
upload = models.FileField(storage=select_storage)
.. versionchanged:: 4.2