Django-storages inserting bucket name as a folder
I'm migrating to Django 5.1.6 (django-storages 1.14.5) from Django 3.2 using DigitalOcean S3-compatible Spaces and when I run python manage.py collectstatic
the bucket name is being inserted as a folder when it used to not be. I want it to be stored in myBucket
as /static/myFile.png
, but it's being stored as /myBucket/static/myFile.png
instead.
In my settings.py file:
STORAGES = {
"default": {
"BACKEND": "django.core.files.storage.FileSystemStorage",
},
"staticfiles": {
"BACKEND": "storages.backends.s3boto3.S3Boto3Storage",
"OPTIONS": {
"secret_key": "mySecretKey",
"access_key": "myAccessKey",
"bucket_name": 'myBucket',
"endpoint_url": 'https://mySubdomain.sfo2.digitaloceanspaces.com/',
"object_parameters": {'CacheControl': 'max-age=86400'},
"location": 'static',
"default_acl": 'public-read',
},
},
}
STATIC_URL = "https://mySubdomain.sfo2.digitaloceanspaces.com/static/"
Am I doing something wrong or is this a bug in django-storages?
Turns out I missed the important caveats for DigitalOcean.
Set
region_name
to your Digital Ocean region (such as nyc3 or sfo2)Set
endpoint_url
to the value ofhttps://${region_name}.digitaloceanspaces.com