有一个意想不到的问题,我最近一次尝试在Heroku上为一个应用程序运行collectstatic时无限期超时:
Running `python manage.py collectstatic` attached to terminal... up, run.6250
/app/.heroku/python/lib/python2.7/site-packages/dotenv.py:16: UserWarning: not reading .env - it doesn't exist.
warnings.warn("not reading %s - it doesn't exist." % dotenv)
You have requested to collect static files at the destination
location as specified in your settings.
This will overwrite existing files!
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes在我输入"yes“后,它挂起并超时,没有错误。当我附加--dry run --noinput时也会发生同样的事情。我的env.txt文件包括
AWS_ACCESS_KEY
AWS_SECRET_ACCESS_KEY
AWS_QUERYSTRING_AUTH = False我很困惑,因为我的代码没有任何变化,而且我之前已经成功地使用这个应用程序运行了一个集合体。
App使用的是使用django-storage而不是S3-boto。下面是我的设置:
if DEBUG:
#dev storage using local
...
else:
# Production AWS S3
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AVATAR_STORAGE_DIR = 'avatars/'
AWS_ACCESS_KEY_ID = env('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = env('AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = env('AWS_STORAGE_BUCKET_NAME')
AWS_QUERYSTRING_AUTH = env('AWS_QUERYSTRING_AUTH', False)
AWS_PRELOAD_METADATA = True
STATIC_URL = 'http://%s.s3.amazonaws.com/' % AWS_STORAGE_BUCKET_NAME
MEDIA_URL = STATIC_URL
ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'所有AWS凭证都在Heroku配置中设置。FWIW我有
heroku labs:enable user-env-compile 已启用
发布于 2015-10-16 05:43:20
将collectfast添加到requirements.txt文件和settings.py中(并检查installation docs)。这是一个救命稻草,特别是当你有很多文件的时候,因为它使用你的缓存设置来存储之前上传的文件的哈希。将它添加到我的许多Django项目中已经极大地改进了静态文件集合(在Heroku的例子中,实际上使它变得可行)。
https://stackoverflow.com/questions/21799234
复制相似问题