I am using AWS and I will have different buckets in my application. I am also using Django-Storages. Is there a way to specify which bucket I want to upload the file to (for
Just mention another bucket name in settings.py with PRIVATE_BUCKET_NAME='bucket name'.
Create a custom class which override S3BotoStorage and which can be serialize into migration files.
Create a object for class s3_storage = S3MediaStorage() and give it to storage in file1 field in MyModel
from storages.backends.s3boto import S3BotoStorage
from django.conf import settings
@deconstructible
class S3MediaStorage(S3BotoStorage):
def __init__(self, *args, **kwargs):
kwargs['bucket'] = getattr(settings, 'PRIVATE_BUCKET_NAME')
super(S3MediaStorage, self).__init__(*args, **kwargs)
s3_storage = S3MediaStorage()
class MyModel(models.Model):
file = models.FileField()
file1 = models.FileField(storage=s3_storage)