In settings.py
I have:
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_ACCESS_KEY_ID = 'xxxxxxxxxxxxx'
AWS_SECRET_ACCESS_KEY = 'xxxxxxxxxxxxx'
AWS_STORAGE_BUCKET_NAME = 'static.mysite.com'
This is pointing to my S3 bucket static.mysite.com
and works fine when I do manage.py collectstatic
, it uploads all the static files to my bucket. However, I have another bucket which I use for different purposes and would like to use in certain areas of the website, for example if I have a model like this:
class Image(models.Model):
myobject = models.ImageField(upload_to='my/folder')
Now when Image.save()
is invoked, it will still upload the file to the S3 bucket in AWS_STORAGE_BUCKET_NAME
, however I want this Image.save()
to be point to another S3 bucket. Any clean way of doing this? I don't want to change settings.py
in run time nor implement any practices that violate the key principles of django, i.e. having a pluggable easy-to-change backend storage.