【发布时间】:2012-02-21 06:06:23
【问题描述】:
我在 heroku 中有一个项目 (myapp),但我无法让静态文件正常工作。我在关注这个blog post。
我的Procfile 看起来像这样:
web: python myapp/manage.py collectstatic --noinput; bin/gunicorn_django --workers=4 --bind=0.0.0.0:$PORT myapp/settings.py
settings.py:
...
STATIC_ROOT = os.path.join(PROJECT_PATH, 'staticfiles')
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/static/admin/'
STATICFILES_DIRS = (
# I have the static folder inside my app and not inside the project
os.path.join(PROJECT_PATH, 'cesar/static'),
)
...
使用heroku restart 重新启动时,heroku logs 显示如下:
...
Copying ...
114 static files copied to '/app/myapp/staticfiles'.
...
但是当我执行heroku run ls -l myapp/ 时,我看不到staticfiles 文件夹:
-rw------- 1 u5605 5605 0 Jan 28 16:53 __init__.py
drwx------ 4 u5605 5605 4096 Jan 28 16:53 cesar
-rw------- 1 u5605 5605 503 Jan 28 16:53 manage.py
-rw------- 1 u5605 5605 6292 Jan 28 16:53 settings.py
drwx------ 2 u5605 5605 4096 Jan 28 16:53 templates
-rw------- 1 u5605 5605 257 Jan 28 16:53 urls.py
-rw------- 1 u5605 5605 286 Jan 28 16:53 views.py
我错过了什么或做错了什么?
【问题讨论】:
-
我最近写了一篇关于从 Heroku 应用程序在 S3 上提供静态文件的详细说明,请查看 - balzerg.blogspot.co.il/2012/09/…