我试图在Heroku上发布一个django项目,但我在静态文件方面遇到了问题。这是我的配置:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
# Extra places for collectstatic to find static files.
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'但是Heroku回来了:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/build_02a3e2abd7f176139303f077e32a2e9b/static'
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: https://devcenter.heroku.com/articles/django-assets
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...我无能为力,我理解这个问题,但不知道如何解决它:(我的项目结构如下:
├── Procfile
├── manage.py
├── my_project
│ ├── __init__.py
│ ├── settings
│ │ ├── __init__.py
│ │ ├── base.py
│ │ ├── dev.py
│ │ └── prod.py
│ ├── urls.py
│ └── wsgi.py
├── requirements.txt
├── runtime.txt
├── static
└── staticfiles关于Django或Heroku的文档没有解释何时按环境拆分设置:(
发布于 2017-04-27 15:26:07
我已经修复了我的问题,只需设置:
MEDIA_ROOT = 'media'
STATIC_ROOT = 'static'https://stackoverflow.com/questions/43639555
复制相似问题