Django与Amazon S3通过boto3:配置不当

2024-04-19 22:08:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我跟随this tutorial创建了带有Django的Amazon S3。 但在使用Python 3.3时,我安装了一个Python-3 compatible fork的django存储和boto3

以下是settings.py文件:

AWS_STORAGE_BUCKET_NAME = os.environ['LIVIN_AWS_STORAGE_BUCKET_NAME']
S3_REGION_NAME = os.environ['LIVIN_S3_REGION_NAME']
AWS_ACCESS_KEY_ID = os.environ['LIVIN_AWS_ACCESS_KEY_ID']
AWS_SECRET_ACCESS_KEY = os.environ['LIVIN_AWS_SECRET_ACCESS_KEY']

AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
STATIC_URL = "https://%s/" % AWS_S3_CUSTOM_DOMAIN

# Tell the staticfiles app to use S3Boto storage when writing the collected
# static files (when you run `collectstatic`).
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'

当我尝试时,python manage.py collectstatic我得到这个错误:

ImportError: No module named 'boto'
During handling of the above exception, another exception occurred:
...
django.core.exceptions.ImproperlyConfigured: Could not load Boto's S3 bindings.
See https://github.com/boto/boto

似乎存储后端是boto,而不是boto3。


Tags: thedjangokeynamepyawss3bucket