1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

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

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