我在这篇文章中找到了解决方案:
http://blog.doismellburning.co.uk/2012/06/25/django-and-static-
files/
http://offbytwo.com/2012/01/18/deploying-django-to-
heroku.html
https://devcenter.heroku.com/articles/s3
基本上我需要下载boto(pip install boto)并将其放在Requirements.txt(pip冻结>
requirements.txt)中,并在settings.py中添加:
INSTALLED_APPS = ('storages',)AWS_ACCESS_KEY_ID = 'xxxxxx'AWS_SECRET_ACCESS_KEY = 'xxxxxxx'AWS_STORAGE_BUCKET_NAME = 'bucket_name'STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'STATIC_URL = 'http://s3.amazonaws.com/%s' % AWS_STORAGE_BUCKET_NAME + '/'然后,您需要设置“ AWS_ACCESS_KEY_ID”,“ AWS_SECRET_ACCESS_KEY”,“
AWS_STORAGE_BUCKET_NAME”
使用
$ heroku config:set AWS_ACCESS_KEY_ID=xxx AWS_SECRET_ACCESS_KEY=yyy$ heroku config:set S3_BUCKET_NAME=appname-assets
更新html中的src和href:
网址http://ishopss.com/url.png
最后,您需要在https://console.aws.amazon.com/中更新权限。



