【发布时间】:2014-01-23 22:02:51
【问题描述】:
我准备将一个 django 项目部署到 heroku。
首先,我发现 staticfiles 目录不是自动创建的,甚至在我运行时也没有
$ heroku run python manage.py collectstatic --noinput
(顺便说一句,不会引发错误)。直到知道它看起来与this question 非常相似。然后我意识到我根本无法通过 heroku shell 创建任何文件或文件夹。
例如:
$ heroku run mkdir EXAMPLE
Running `mkdir EXAMPLE` attached to terminal... up, run.7925
$ heroku run ls
Running `ls` attached to terminal... up, run.1406
total 32
BLAH BLAH BLAH NO EXAMPLE DIR HERE
同理:
$ heroku run touch EXAMPLE.txt
另一方面,运行时:
$ heroku run bash
一切看起来都很好,甚至是静态的。文件被收集、编辑、创建,等等。但是在退出 bash 终端并运行之后
$ heroku run ls
它仍然显示同样的问题,没有任何变化。
也许我错过了什么......
解决方案
感谢 friism,我尝试了不同的方法。最后,唯一必要的更改是将 Procfile 更改为
web: python manage.py collectstatic --noinput; gunicorn app-name.wsgi
强制静态收集。
再次感谢汤姆
【问题讨论】: