From 506f93f0c37ed9c44069edeab8baa66da5f7e03a Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Tue, 2 May 2023 21:32:24 +0300 Subject: [PATCH] Fixed #34530 -- Improved docs when customizing storage for FileField. --- docs/topics/files.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/topics/files.txt b/docs/topics/files.txt index fa4a14a7e79..9ec4b0dc665 100644 --- a/docs/topics/files.txt +++ b/docs/topics/files.txt @@ -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