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:
parent
c61219a7ae
commit
506f93f0c3
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user