I followed this tutorial to set up Amazon S3 with Django. But as I'm using Python 3.3, I installed a Python-3 compatible fork of django-storages and boto3 instead.
Here is settings.py file:
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'
When I try, python manage.py collectstatic
I get this error:
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
It seems the storage backend is the boto one, not the boto3 one.
All the configuration is OK, it's just a confusion. To configure Amazon S3 with Django and Python 3+, I have to use :
So, pip install django-storages-redux, boto
will work like a charm :)
Django-storages has built in python3 support now. To use django storages with boto3 the following worked for me:
pip install boto3
pip install django-storages==1.5.1 --> only version 1.5 and above have boto3 support.
use the following staticfiles_storage setting
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
instead of:
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
I follow to line of code error in file storages\backends\s3boto.py
and found this error is missing package google_compute_engine
Solution: pip install google_compute_engine
and collectstatic
again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With