S3StaticStorage backend not found in django-storages s3boto3 module

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?

You’re using the wrong backend class in your STORAGES config. S3StaticStorage doesn’t exist in django-storages - use S3Boto3Storage instead. I hit this same issue during a production deploy last year. Change your STORAGES setting to use storages.backends.s3boto3.S3Boto3Storage for both default and staticfiles backends. Also, ditch the DEFAULT_FILE_STORAGE setting since you’re already defining storage backends in the STORAGES dictionary. Media files work because they’re probably using the DEFAULT_FILE_STORAGE setting which correctly points to S3Boto3Storage, but your static files are trying to use the non-existent S3StaticStorage class.

you mixed up the class names. S3StaticStorage doesn’t exist in django-storages anymore - just use S3Boto3Storage for both backends in your STORAGES dict. had the same issue a few months back and that’s what fixed it.