Skip to content

Commit

Permalink
Add another use case example
Browse files Browse the repository at this point in the history
  • Loading branch information
miigotu committed Oct 22, 2018
1 parent c063935 commit 535ca97
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/topics/files.txt
Expand Up @@ -216,6 +216,14 @@ storage on one deployment, but local storage on another.

return super(MyCustomStorage2, self).__init__(...)

class MyStorage(Storage):
# Adding a call method makes the instance callable
def __call__(self):
if ...:
self.location = ...
return self

class MyModel(models.Model):
my_file = models.FileField(storage=MyCustomStorage)
my_image = models.ImageField(storage=MyCustomStorage2)
my_image2 = models.ImageField(storage=MyStorage())

0 comments on commit 535ca97

Please sign in to comment.