Writing a custom storage system
Writing a custom storage system
If you need to provide custom file storage – a common example is storing files on some remote system – you can do so by defining a custom storage class. You’ll need to follow these steps:
-
Your custom storage system must be a subclass of
django.core.files.storage.Storage
:from django.core.files.storage import Storage class MyStorage(Storage): ...
-
Django must be able to instantiate your storage system without any arguments. This means that any settings should be taken from
django.conf.settings
:from django.conf import settings from django.core.files.storage import Storage class MyStorage(Storage): def __init__(self, option=None): if not option: option = settings.CUSTOM_STO