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
Another solution if you want to specify bucket on the runtime, you can do so before invoking the save() method on the model.
Following the above example:
from django.db import models
from storages.backends.s3boto import S3BotoStorage
class MyModel(models.Model):
file_1 = models.FileField() # Uses default storage
file_2 = models.FileField()
In views when saving the model, you can specify the storage on that field.
my_file_model = MyModel()
my_file_model.file_2.storage = S3BotoStorage(bucket="your-bucket-name")
my_file_model.save()
In this way file_2 will be saved in the bucket you specify where file_1 will use your default bucket.