我在heroku中有一个项目(myapp),但无法使静态文件正常工作。我正在关注这个blog post。Heroku - 处理Django应用程序中的静态文件
我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上提供静态文件的详细解释,请查看 - http://balzerg.blogspot.co.il/2012/09/staticfiles-on -heroku-with-django.html – idanzalz 2012-09-09 09:05:32