python - 为什么项目无法推送到Heroku?

查看:372
本文介绍了python - 为什么项目无法推送到Heroku?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

按教程将项目推送到heroku,前面步骤一切顺利没有任何错误,直到这里出现问题在网上没有找到解决方法。。。

感觉好像是setting.py的设置有问题,但和教程里对照是一样的:

heroku的设置

if os.getcwd()=='/app':

import dj_database_url
DATABASES={
    'default':dj_database_url.config(default='postgres://localhost')
}

SECURY_PROXY_SSL_HEADER=('HTTP_X_FORWARDED_PROTO','https')

ALLOWED_HOSTS = ['*']

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = 'staticfiles'
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)

命令行的报错:

(ll_env) G:python_dorest>heroku create
Creating app... done, protected-crag-1803
https://protected-crag-1803.h... | https://git.heroku.com/protec...

(ll_env) G:python_dorest>git push heroku master
Counting objects: 48, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (39/39), done.
Writing objects: 100% (48/48), 11.18 KiB | 0 bytes/s, done.
Total 48 (delta 3), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-3.5.2

—————————中间内容省略—————————

remote: File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/storage.py", line 50, in path
remote: raise ImproperlyConfigured("You're using the staticfiles app "
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'.
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/...
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to protected-crag-1803.
remote:
To https://git.heroku.com/protec...
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/protec...'

解决方案

好好看错误日志啊:

remote: File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/storage.py", line 50, in path
remote: raise ImproperlyConfigured("You're using the staticfiles app "
remote: django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.

这篇关于python - 为什么项目无法推送到Heroku?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆