I’m having trouble with my Django project deployment. When I try to run collectstatic, I get an error saying it cannot find the S3StaticStorage backend.
Here’s the error I’m seeing:
django.core.files.storage.handler.InvalidStorageError: Could not find backend 'storages.backends.s3boto3.S3StaticStorage': Module "storages.backends.s3boto3" does not define a "S3StaticStorage" attribute/class
My current settings.py configuration looks like this:
STATIC_ROOT = os.path.join(BASE_DIR, 'static_files')
STATIC_URL = '/assets/'
AWS_ACCESS_KEY_ID = config('AWS_KEY_ID')
AWS_SECRET_ACCESS_KEY = config('AWS_SECRET_KEY')
AWS_STORAGE_BUCKET_NAME = config('S3_BUCKET_NAME')
AWS_S3_CUSTOM_DOMAIN = f'{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com'
AWS_DEFAULT_ACL = 'public-read'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
AWS_MEDIA_LOCATION = 'uploads'
MEDIA_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/{AWS_MEDIA_LOCATION}/'
STORAGES = {
"default": {
"BACKEND": "storages.backends.s3boto3.S3StaticStorage",
},
"staticfiles": {
"BACKEND": "storages.backends.s3boto3.S3StaticStorage",
},
}
I already tried reinstalling django-storages and all the AWS packages but nothing changed. The weird thing is that media files work fine in development, so the S3 connection itself seems okay. What am I missing in my static files setup?