1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #31941 -- Corrected FileField.deconstruct() with a callable storage.

This commit is contained in:
Brian Helba
2020-08-24 15:27:22 -04:00
committed by Carlton Gibson
parent ece18207cb
commit 2d42e23b6d
4 changed files with 18 additions and 3 deletions

View File

@@ -229,6 +229,8 @@ class FileField(Field):
self.storage = storage or default_storage
if callable(self.storage):
# Hold a reference to the callable for deconstruct().
self._storage_callable = self.storage
self.storage = self.storage()
if not isinstance(self.storage, Storage):
raise TypeError(
@@ -279,7 +281,7 @@ class FileField(Field):
del kwargs["max_length"]
kwargs['upload_to'] = self.upload_to
if self.storage is not default_storage:
kwargs['storage'] = self.storage
kwargs['storage'] = getattr(self, '_storage_callable', self.storage)
return name, path, args, kwargs
def get_internal_type(self):