Django with Amazon S3 via boto3: Incorrectly configured

I followed this tutorial to set up Amazon S3 with Django. But since I am using Python 3.3, I installed a Python-3 compatible fork of django storages and boto3 .

Here is the 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 S3 bindings. See https://github.com/boto/boto 

The memory backend seems to be boto one, not boto3.

+5
source share
3 answers

The whole configuration is fine, it's just confusion. To configure Amazon S3 with Django and Python 3+, I have to use:

  • Python 3 compatible django repositories (called django-storages-redux)
  • Standard boto package (boto3 has nothing to do with Python actually ..)

So pip install django-storages-redux, boto will work like a charm :)

+6
source

Django repositories are now built into python3 support. To use django repositories 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 parameter

 STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' 

instead:

 STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage' 
+2
source

I follow the line of code error in the file storages\backends\s3boto.py and found that the google_compute_engine package is missing from this error

enter image description here

enter image description here

enter image description here

Solution: pip install google_compute_engine and collectstatic again.

+1
source

All Articles