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)
Here's what I did:
Installed django storages
pip install django-storages
Added it to my INSTALLED_APPS
#settings.py
INSTALLED_APPS = (
...
'storages',
)
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
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.
How can I set this up correctly?
Had this issue recently on TravisCI with a Django repo
Running
python manage.py compress
failed with the error:It happened to be an issue with boto trying to import
google-compute-engine
module that was not installed.One way to fix the problem is by installing GCE engine with
pip install google-compute-engine
EDIT:
After investigation, it appears that this particular problem is due to Travis being on GCE, and GCE having a default
/etc/boto.cfg
file, which prompts boto to look for the GCE engine.Another way to fix this problem on Travis without installing more dependencies is to set the default config with
BOTO_CONFIG
to point to nowhere by setting the variableBOTO_CONFIG=/tmp
in your
travis.yml
See this Issue https://github.com/boto/boto/issues/3741
The link in the error message, http://developer.amazonwebservices.com/connect/entry.jspa?externalID=134, seems to work now (June 2014). If you follow it and download, unpack the .zip file and put
S3.py
on your Python path (i.e. insite-packages
), it all works.in answer to your comment above, it sounds like you are using the wrong settings, check this one:
For the First setting you are trying i.e :
It means if the code for storage is present in your 'libs.storages' directory in your python path, then it should be accessed like above.
But if you have installed django-storages using setup.py or pip or easy_install, then following 2 options are there:
A. Amazone S3Python based library:
B. Python Boto based library:
Based on python boto, and supports much advanced features e.g. connection pooling etc.
But you are required to install python boto for using it, e.g
pip install boto
Do you have python-boto installed?
pip install boto
orpip install boto3
Consider using boto3 instead of the older boto:
requirements.txt:
settings.py: