1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #34192 -- Preserved callable storage when it returns default_storage.

This commit is contained in:
Matt Westcott
2023-01-20 18:10:29 +00:00
committed by Mariusz Felisiak
parent e3a4cee081
commit ef85b6bf0b
3 changed files with 27 additions and 4 deletions

View File

@@ -9,7 +9,7 @@ import random
import tempfile
from pathlib import Path
from django.core.files.storage import FileSystemStorage
from django.core.files.storage import FileSystemStorage, default_storage
from django.db import models
@@ -27,6 +27,10 @@ def callable_storage():
return temp_storage
def callable_default_storage():
return default_storage
class CallableStorage(FileSystemStorage):
def __call__(self):
# no-op implementation.
@@ -62,6 +66,9 @@ class Storage(models.Model):
storage_callable_class = models.FileField(
storage=CallableStorage, upload_to="storage_callable_class"
)
storage_callable_default = models.FileField(
storage=callable_default_storage, upload_to="storage_callable_default"
)
default = models.FileField(
storage=temp_storage, upload_to="tests", default="tests/default.txt"
)