You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署Django应用到Heroku时collectstatic报错,推送被拒绝

Django部署Heroku时Collectstatic报错,已尝试常见方案仍未解决

我正在将Django应用部署到Heroku的过程中,遇到了collectstatic阶段的报错,和社区里一篇关于该问题的经典帖子情况完全一致。整个构建、依赖下载及安装流程都顺利完成,但在执行静态文件收集步骤时失败,具体报错日志如下:

$ 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: ! 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'

我已经尝试了以下方案,但问题仍然没有解决:

  • 完全照搬了那篇经典帖子里的所有解决方案
  • 参照Heroku开发者中心的Django静态资源配置文档,完成了相关设置并安装了whitenoise库
  • 提交所有修改后重新推送部署,报错依旧出现

内容的提问来源于stack exchange,提问作者Wizard

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 03:59:49