I can't figure out how to set up django-storages. All of the directions seem to be incomplete or something.
I've tried: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html http://blog.doismellburning.co.uk/2012/07/14/using-amazon-s3-to-host-your-django-static-files/ and a couple others that I cannot find now.
This is a setup checklist that I made for my colleagues.
settings_local.py
.Still in IAM, set user access permissions:
This policy allows access to all buckets to the user group:
Now, the bucket is set, the users have access to it. You can try setting and testing access to the bucket from Django.
Install the following packages:
I added this code to
settings_local.py
to not expose it to those who view commits:This code goes to
settings.py
:Go to AWS S3 section and get the url for your bucket, paste it into settings files, set
STATIC_URL
accordingly.Paste keys from credentials into settings_local.py. Now Django should be able to upload static files to the storage.
Run this command:
If it uploads files, then everything is correct. If not, check the error messages.
pyflakes your_project/settings*.py
).Just to check the files are accessible from the web, paste the bucket's S3 web url into STATIC_URL. Run Django and see where the statc assets come from.
If you want CloudFront, it's some more steps.
In AWS, go to Services > Storage & Content Delivery > CloudFront. Create a distribution. Distribution is like a virtual web server with access to a folder.
Choose:
Go to the new distribution settings and copy the domain name. Paste it as
STATIC_URL
insettings_local.py
file. The newSTATIC_URL
from CloudFront should not contain the bucket name, because this domain name is specifically for that bucket.This URL is a sensitive data in the sense that access to it costs you real money and is slower than a local dev server, so probably it should not run on development environment.
Hope this helps.