I am trying to create a new custom storage class based off S3BotoStorage and I keep getting this error with the following code:
import sys
from django.core.files.storage import Storage
from storages.backends.s3boto import S3BotoStorage
class customStorage(S3BotoStorage):
def __init__(self, *args, **kwargs):
kwargs['bucket_name'] = 'bucket_1'
print >> sys.stderr, 'Creating MyS3Storage'
super(S3BotoStorage, self).__init__(*args, **kwargs)
Error:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
self._setup()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/files/storage.py", line 285, in _setup
self._wrapped = get_storage_class()()
File "/Users/abisson/Sites/poka/common/storages/models.py", line 10, in __init__
super(S3BotoStorage, self).__init__(*args, **kwargs)
TypeError: object.__init__() takes no parameters
I based my answer off Pointing to multiple S3 buckets in s3boto and it should work no? Even normally, we can do:
obj1 = models.FileField(storage=S3BotoStorage(bucket='bucket_1'), upload_to=custom_upload_to)
and it works. (and do pass an argument to the constructor)