Django存储-无法加载Amazon的S3绑定错误 [英] Django Storages - Could Not Load Amazon's S3 Bindings Errors

查看:96
本文介绍了Django存储-无法加载Amazon的S3绑定错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,所以尝试将我的用户上传的图像连接到我的S3存储桶,以便将图像存储在那里.使用Django存储(做了一些研究,似乎每个人都在建议这样做,但是有很多想法可以接受)

Hey so trying to connect my user uploaded images to my S3 bucket so the images will store there. Using django storages (did some research, seemed to be what everyone suggested, but open to ideas)

这就是我所做的:

已安装的django存储

Installed django storages

pip install django-storages

将其添加到我的INSTALLED_APPS

Added it to my INSTALLED_APPS

#settings.py
INSTALLED_APPS = (
...
'storages',
)

并将此代码也添加到settings.py

And added this code as well to settings.py

#settings.py
DEFAULT_FILE_STORAGE = 'storages.backends.s3.S3Storage'
AWS_ACCESS_KEY_ID = '#################'
AWS_SECRET_ACCESS_KEY = '#######################'
AWS_STORAGE_BUCKET_NAME = 'mybucketname'

然后我打开外壳并运行它进行检查

Then I open the shell and run this to check

from django.core.files.storage import default_storage
print default_storage.connection
...
ImproperlyConfigured: Could not load amazon's S3 bindings.
See http://developer.amazonwebservices.com/connect/entry.jspa?externalID=134

链接导致404错误.一直跟随文档并尝试了所有三种设置DEFAULT_FILE_STORAGE的方法,但它们都不起作用.见下文.

The link leads to a 404 error. Have been following along with the documentation and tried all 3 ways to set up DEFAULT_FILE_STORAGE, and none of them work. See below.

DEFAULT_FILE_STORAGE = 'libs.storages.backends.S3Storage.S3Storage'
ImproperlyConfigured: Error importing storage module libs.storages.backends.S3Storage

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
ImproperlyConfigured: Could not load Boto's S3 bindings.

如何正确设置?

推荐答案

您已安装python-boto吗?
pip install boto 或者 pip install boto3

Do you have python-boto installed?
pip install boto or pip install boto3

这篇关于Django存储-无法加载Amazon的S3绑定错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆