为了账号安全,请及时绑定邮箱和手机立即绑定

为什么项目无法推送到Heroku?

为什么项目无法推送到Heroku?

杨__羊羊 2019-05-25 18:00:06
按教程将项目推送到heroku,前面步骤一切顺利没有任何错误,直到这里出现问题在网上没有找到解决方法。。。感觉好像是setting.py的设置有问题,但和教程里对照是一样的:heroku的设置ifos.getcwd()=='/app':importdj_database_urlDATABASES={'default':dj_database_url.config(default='postgres://localhost')}SECURY_PROXY_SSL_HEADER=('HTTP_X_FORWARDED_PROTO','https')ALLOWED_HOSTS=['*']BASE_DIR=os.path.dirname(os.path.abspath(__file__))STATIC_ROOT='staticfiles'STATICFILES_DIRS=(os.path.join(BASE_DIR,'static'),)命令行的报错:(ll_env)G:python_dorest>herokucreateCreatingapp...done,protected-crag-1803https://protected-crag-1803.h...|https://git.heroku.com/protec...(ll_env)G:python_dorest>gitpushherokumasterCountingobjects:48,done.Deltacompressionusingupto4threads.Compressingobjects:100%(39/39),done.Writingobjects:100%(48/48),11.18KiB|0bytes/s,done.Total48(delta3),reused0(delta0)remote:Compressingsourcefiles...done.remote:Buildingsource:remote:remote:----->Pythonappdetectedremote:----->Installingpython-3.5.2—————————中间内容省略—————————remote:File"/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/storage.py",line50,inpathremote:raiseImproperlyConfigured("You'reusingthestaticfilesapp"remote:django.core.exceptions.ImproperlyConfigured:You'reusingthestaticfilesappwithouthavingsettheSTATIC_ROOTsettingtoafilesystempath.remote:remote:!Errorwhilerunning'$pythonmanage.pycollectstatic--noinput'.remote:Seetracebackabovefordetails.remote:remote:Youmayneedtoupdateapplicationcodetoresolvethiserror.remote:Or,youcandisablecollectstaticforthisapplication:remote:remote:$herokuconfig:setDISABLE_COLLECTSTATIC=1remote:remote:https://devcenter.heroku.com/...remote:!Pushrejected,failedtocompilePythonapp.remote:remote:!Pushfailedremote:Verifyingdeploy...remote:remote:!Pushrejectedtoprotected-crag-1803.remote:Tohttps://git.heroku.com/protec...![remoterejected]master->master(pre-receivehookdeclined)error:failedtopushsomerefsto'https://git.heroku.com/protec...'
查看完整描述

2 回答

?
蝴蝶不菲

TA贡献1810条经验 获得超4个赞

Youmayneedtoupdateapplicationcodetoresolvethiserror.remote:Or,youcandisablecollectstaticforthisapplication:remote:remote:$herokuconfig:setDISABLE_COLLECTSTATIC=1
显示可能是heroku服务器已经有一个静态文件占位了,所以要删掉它。执行命令:herokuconfig:setDISABLE_COLLECTSTATIC=0
我也遇到了同样的问题,用这种方法解决了,希望能帮助你和后来者~
                            
查看完整回答
反对 回复 2019-05-25
  • 2 回答
  • 0 关注
  • 715 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号