Could not find backend 'storages.backends.s3boto3.S3StaticStorage'

When deploying my Django app it just (seems like) stopped to connect to my S3 bucket. The full message I get when running collectstatic is

Traceback (most recent call last):
  File "/home/ubuntu/campmanager/manage.py", line 22, in <module>
    main()
  File "/home/ubuntu/campmanager/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/home/ubuntu/.local/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/django/core/management/base.py", line 416, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/django/core/management/base.py", line 460, in execute
    output = self.handle(*args, **options)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 184, in handle
    if self.is_local_storage() and self.storage.location:
  File "/home/ubuntu/.local/lib/python3.10/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 245, in is_local_storage
    return isinstance(self.storage, FileSystemStorage)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/django/utils/functional.py", line 280, in __getattribute__
    value = super().__getattribute__(name)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/django/utils/functional.py", line 251, in inner
    self._setup()
  File "/home/ubuntu/.local/lib/python3.10/site-packages/django/contrib/staticfiles/storage.py", line 542, in _setup
    self._wrapped = storages[STATICFILES_STORAGE_ALIAS]
  File "/home/ubuntu/.local/lib/python3.10/site-packages/django/core/files/storage/handler.py", line 34, in __getitem__
    storage = self.create_storage(params)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/django/core/files/storage/handler.py", line 45, in create_storage
    raise InvalidStorageError(f"Could not find backend {backend!r}: {e}") from e
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

This is my setting in settings.py

STATIC_ROOT = os.path.join(CORE_DIR, 'staticfiles')
STATIC_URL = 'static/'

AWS_ACCESS_KEY_ID = env('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = env('AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = env('AWS_STORAGE_BUCKET_NAME')
AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
AWS_DEFAULT_ACL = 'public-read'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
AWS_MEDIA_LOCATION = 'media-dev'
MEDIA_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, AWS_MEDIA_LOCATION)
S3_URL = 'https://%s/' % (AWS_S3_CUSTOM_DOMAIN)
STORAGES = {
   "default": {
        "BACKEND" : "storages.backends.s3boto3.S3StaticStorage",
    },

    "staticfiles":  {
        "BACKEND" : "storages.backends.s3boto3.S3StaticStorage",
    },
}

I have tried to uninstalled and reinstalled django-storages, boto3 and botocore no change, in hope it would fix the problem. No change.

Since I can use the bucket in development (for media files) it should logically have to do with my staticfile settings. But I can't come up with what is the problem. Perhaps another set of eyes could help me out?

Вернуться на верх