You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
来源:互联网 发布:php实现uv pv ip统计 编辑:程序博客网 时间:2024/06/07 00:43
【问题】Heroku部署报错:
remote: django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.remote: remote: ! Error while running '$ python manage.py collectstatic --noinput'.
【分析原因】
1.错误提示没有设置STATIC_ROOT,查看设置STATIC_ROOT的原py文件:
settings.py:
# Heroku设置if os.getcwd() == '/app': import dj_database_url DATABASES = { 'default': dj_database_url.config(default='postgres://localhost') } SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') ALLOWED_HOSTS = ['*'] PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) STATIC_ROOT = 'staticfiles' STATICFILES_DIRS = ( os.path.join(PROJECT_ROOT, 'static'), )
可以看到,settings.py中设置了STATIC_ROOT,没生效的原因是if 模块条件不满足。
2.设置debug模式查看变量:
heroku config:set DEBUG_COLLECTSTATIC=1
参见官网:https://devcenter.heroku.com/articles/django-assets
remote: ****** Collectstatic environment variables:remote: remote: CPLUS_INCLUDE_PATH=/app/.heroku/vendor/include:/app/.heroku/python/include:remote: EXPORT_PATH=/app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51/bin/../exportremote: SOURCE_VERSION=cd6b464f5547d9ad4e76d44a43726bebb7c30368remote: PROFILE_PATH=/tmp/build_cfa1044d9f6f7ba51f5503a4fd86a6e2/.profile.d/python.shremote: DEBUG_COLLECTSTATIC=1remote: BUILDPACK_LOG_FILE=/dev/fd/3remote: LIBRARY_PATH=/app/.heroku/vendor/lib:/app/.heroku/python/lib:remote: CACHE_DIR=/app/tmp/cacheremote: PYTHONUNBUFFERED=1remote: DEFAULT_PYTHON_STACK=cedar-14remote: LD_LIBRARY_PATH=/app/.heroku/vendor/lib:/app/.heroku/python/libremote: BIN_DIR=/app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51/binremote: DYNO=run.6619remote: PATH=/app/.heroku/python/bin:/app/.heroku/vendor/bin::/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/tmp/codon/vendor/bin:/app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51/vendor/:/app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51/vendor/pip-popremote: ENV_DIR=/tmp/d20171027-69-1ccgm4mremote: RECOMMENDED_PYTHON_VERSION=python-3.6.2remote: C_INCLUDE_PATH=/app/.heroku/vendor/include:/app/.heroku/python/include:remote: PWD=/tmp/build_cfa1044d9f6f7ba51f5503a4fd86a6e2remote: BPLOG_PREFIX=buildpack.pythonremote: LANG=en_US.UTF-8remote: CACHED_PYTHON_STACK=heroku-16remote: STACK=heroku-16remote: SHLVL=3remote: REQUEST_ID=cb62d053-d9e7-58a0-a77c-eeed27ca3efaremote: HOME=/appremote: LATEST_2=python-2.7.14remote: LATEST_3=python-3.6.2remote: PIP_UPDATE=9.0.1remote: BUILD_DIR=/tmp/build_cfa1044d9f6f7ba51f5503a4fd86a6e2remote: WARNINGS_LOG=/tmp/tmp.QRkojcYlAeremote: DEFAULT_PYTHON_VERSION=python-3.6.2remote: PKG_CONFIG_PATH=/app/.heroku/vendor/lib/pkgconfig:/app/.heroku/vendor/lib/pkg-config:/app/.heroku/python/lib/pkg-config:remote: _=/usr/bin/env
可以看到,当前工作目录不是'/app'
,且每次生成的目录都不一样(build后面的一串不固定),应该获取HOME目录。
PWD=/tmp/build_cfa1044d9f6f7ba51f5503a4fd86a6e2HOME=/app
【解决方法】
if os.getcwd() == '/app': #获取当前工作目录改为:if os.environ['HOME'] == '/app': #获取HOME目录
阅读全文
0 0
- You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
- You're using the staticfiles app without having set the STATIC_ROOT setting
- Are you looking for a way to get the entire text of a word document into a RichEdit without using the Clipboard?
- The IP you're using to send email is not authorized
- svnsync问题: have you committed to the destination without using svnsync
- How do you remove the duplicate characters in a given string without using any additional buffer.
- 如何解决It's likely you're attempting to run Eclipse using the JRE instead of the JDK
- Close a IE11 window without receiving the “Do you want to close this window” prompt?
- 让国外邮件服务商不再拒收你的邮件,The IP you're using to send mail is not authorized
- .....an attempt to load the C runtime library without using a manifest.....
- [转贴]19 things to think about when you're having a bad day
- use `xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command
- You’re given an array containing both positive and negative integers and required to find the sub-a
- 109 You want to take a complete database backup using RMAN. The backup should consist only the used
- Delete a node WITHOUT using the HEAD pointer.
- load the C runtime library without using a manifest
- load the C runtime library without using a manifest
- When running gradle with java 5, 6 or 7, you must set the path to jdk8, either with property retrola
- BZOJ1854: [Scoi2010]游戏
- 日历
- python中NumPy的常见用法
- 【Linux】Mysql初始化root密码和允许远程访问
- freemarker在servlet中的使用
- You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
- 最长递增子序列
- C++ 控制台打印无输出 无法查找或打开PDB文件
- Spring集成redis缓存
- 【1】coreML入门之结合ARKit场景展示
- Hdu-6183 Color it(cdq分治)
- 关于C#中readonly的变量赋值问题。
- Java
- laravel 添加触发事件