【发布时间】:2013-01-10 08:55:08
【问题描述】:
我有 Django 设置来收集我的静态文件并使用 django-storages 将它们复制到 S3 中,当我明确运行时,这就像一个魅力
heroku run python manage.py collectstatic
但是,我希望 Heroku 在部署时自动执行此操作(即 git push 到 Heroku),如本文档 https://devcenter.heroku.com/articles/django-assets 中所述。显然,输出:
python manage.py collectstatic --dry-run --noinput
确定 collectstatic 是否配置正确(当我明确运行它时,collectstatic 可以正常工作)。我明白了:
$ heroku run python manage.py collectstatic --dry-run --noinput
Running `python manage.py collectstatic --dry-run --noinput` attached to terminal... up, run.9607
Pretending to copy '/app/app_pkg/static/robots.txt'
.... # Lot of similar outputs not shown
16 static files copied.
这对我来说看起来不错,但文档没有指定我应该看到什么。当我部署项目时,一切似乎都工作正常并成功完成。
-----> Installing dependencies using Pip (1.2.1)
Cleaning up...
-----> Collecting static files
16 static files copied.
-----> Discovering process types
Procfile declares types -> web
但这些文件并未显示在我的 S3 存储桶中。如果我然后显式运行
heroku run python manage.py collectstatic
所有文件都显示在 S3 存储桶中。我认为 Heroku 应该为我执行此操作,但我不确定为什么不这样做。这是预期的行为吗?我需要自己做吗?
【问题讨论】:
-
有关similar thread 的更多信息。我也没有找到解决办法。
-
$ heroku labs:enable user-env-compile