由Heroku拒绝推送以获取静态文件收集原因

时间:2018-05-16 12:51:59

标签: django

当我尝试将Django应用程序部署到Heroku时遇到与python - Collectstatic error while deploying Django app to Heroku - Stack Overflow相同的问题。 它开始构建,下载和安装所有东西,但这就是我在收集静态文件时得到的:

$ git push heroku master
Counting objects: 5375, done.
Total 5375 (delta 1092), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Python app detected
remote: -----> Installing requirements with pip
remote: 
...
remote: 
remote:  !     Error while running '$ python manage.py collectstatic --noinput'.
remote:        See traceback above for details.
remote: 
remote:        You may need to update application code to resolve this error.
remote:        Or, you can disable collectstatic for this application:
remote: 
remote:           $ heroku config:set DISABLE_COLLECTSTATIC=1
remote: 
remote:        https://devcenter.heroku.com/articles/django-assets
remote:  !     Push rejected, failed to compile Python app.
remote: 
remote:  !     Push failed
remote: Verifying deploy....
remote: 
remote: !   Push rejected to fierce-cove-94300.
remote: 
To https://git.heroku.com/fierce-cove-94300.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/fierce-cove-94300.git'

我尝试了所有答案,但没有帮助。 另外,我尝试Django and Static Assets | Heroku Dev Center配置设置并安装whitenoise并提交更改。

问题没有解决。

1 个答案:

答案 0 :(得分:1)

禁用auto collectstatic:

heroku config:set DISABLE_COLLECTSTATIC=1

然后将您的项目推送到heroku。部署完成后,手动收集静态,如下所示:

heroku run python manage.py collectstatic

如果仍然出现错误,可能是您的静态文件配置。尝试简单,删除whitenoise并使用s3桶。