我按照以下网址将我的静态文件移动到Amazon S3。
http://blog.doismellburning.co.uk/2012/07/14/using-amazon-s3-to-host-your-django-static-files/
这是我在settings.py中的静态配置
if not DEBUG:
INSTALLED_APPS += ('storages',)
AWS_STORAGE_BUCKET_NAME = os.environ['mybucket']
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
STATIC_URL = 'http://%s.s3.amazonaws.com/'%AWS_STORAGE_BUCKET_NAME
else:
STATIC_URL = '/static/'
STATIC_ROOT = ''
# Additional locations of static files
STATICFILES_DIRS = (
('assets',os.path.join(PROJECT_DIR, '../static')),
)
此后我尝试
python manage.py collectstatic
我收到以下消息
Unknown command: 'collectstatic'
可能是什么问题。我没有在任何地方设置Aws Access Key。,Secret Key。
答案 0 :(得分:1)
将staticfiles应用添加到已安装的应用中。
'django.contrib.staticfiles',
collectstatic
由以上应用管理。