将Django部署到Heroku - 推送被拒绝

时间:2016-03-18 16:38:57

标签: python django git heroku

请重定向到此问题的更新2 部分:)

我正在尝试将我的Django应用程序部署到heroku,当我执行git push heroku master command时出现错误

您知道我收到此错误的原因吗?

(uleague) ➜ pickapp git:(master) ✗ git push heroku master
Counting objects: 195, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (92/92), done.
Writing objects: 100% (195/195), 516.34 KiB | 0 bytes/s, done.
Total 195 (delta 93), reused 195 (delta 93)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: 
remote: ! Push rejected, no Cedar-supported app detected
remote: HINT: This occurs when Heroku cannot detect the buildpack
remote: to use for this application automatically.
remote: See https://devcenter.heroku.com/a...
remote: 
remote: Verifying deploy...
remote: 
remote: !   Push rejected to shielded-crag-57385.
remote: 
To https://git.heroku.com/shielde...
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/shielde...
(uleague) ➜ pickapp git:(master) ✗

我有以下结构目录:

enter image description here

我按照getting started tutorial for deploy in heroku web page并在他们的示例中,requirements.txt和settings.py作为根项目中的隔离文件,而不是作为设置/文件夹或者需求/文件夹嵌套在文件夹下/ p>

这与我拒绝推送的错误有关吗?

更新1

我尝试创建一个requirements.txt文件,其中包含-r requirements/production.txt

这样我的结构目录就已经存在了:

enter image description here

需求/ production.txt的内容是:

-r base.txt
gunicorn==19.4.5
dj-database-url==0.4.0

我得到同样的错误:

(uleague) ➜  pickapp git:(master) ✗ git push heroku master
Counting objects: 195, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (92/92), done.
Writing objects: 100% (195/195), 516.34 KiB | 0 bytes/s, done.
Total 195 (delta 93), reused 195 (delta 93)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: 
remote:  !     Push rejected, no Cedar-supported app detected
remote: HINT: This occurs when Heroku cannot detect the buildpack
remote:       to use for this application automatically.
remote: See https://devcenter.heroku.com/articles/buildpacks
remote: 
remote: Verifying deploy....
remote: 
remote: !   Push rejected to fuupbol.
remote: 
To https://git.heroku.com/fuupbol.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/fuupbol.git'
(uleague) ➜  pickapp git:(master) ✗ git push heroku master
Counting objects: 195, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (92/92), done.
Writing objects: 100% (195/195), 516.34 KiB | 0 bytes/s, done.
Total 195 (delta 93), reused 195 (delta 93)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: 
remote:  !     Push rejected, no Cedar-supported app detected
remote: HINT: This occurs when Heroku cannot detect the buildpack
remote:       to use for this application automatically.
remote: See https://devcenter.heroku.com/articles/buildpacks
remote: 
remote: Verifying deploy....
remote: 
remote: !   Push rejected to fuupbol.
remote: 
To https://git.heroku.com/fuupbol.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/fuupbol.git'
(uleague) ➜  pickapp git:(master) ✗ 

我不知道解决这个问题的方法。 :(

更新2 - 当前状况/挑战

我的错误是我在推动之前没有进行commit操作...... 对不起新手的情况...

我创建了commit并且部署过程正在启动,但现在我有以下与我的SECRET_KEY环境变量相关的错误

当我执行git push heroku master我的控制台时:

nf/__init__.py", line 120, in __init__
remote:            raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
remote:        django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
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: 
remote:  !     Push rejected, failed to compile Python app
remote: 
remote: Verifying deploy....
remote: 
remote: !    Push rejected to fuupbol.
remote: 
To https://git.heroku.com/fuupbol.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/fuupbol.git'
(uleague) ➜  pickapp git:(master) ✗ 

关于SECRET_KEY错误

 nf/__init__.py", line 120, in __init__
    remote:            raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
    remote:        django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

我的项目有不同的设置,考虑到不同的环境。结构目录是:

pickapp/pickapp/settings/base.py
pickapp/pickapp/settings/development.py
pickapp/pickapp/settings/production.py 
pickapp/pickapp/settings/testing.py

pickapp/pickapp/settings/base.py我已经设置了这种方式的SECRET_KEY变量:

# SECURITY WARNING: keep the secret key used in production secret!
def get_env_variable(var_name):
    try:
        return os.environ[var_name]
    except KeyError:
        error_msg = "Set the %s environment variable" % var_name
        raise ImproperlyConfigured(error_msg)

SECRET_KEY = get_env_variable('SECRET_KEY')

这是因为在我的操作系统中(virtualenvwrapper目录配置的VIRTUAL_ENV / bin / postactivate)我有类似的东西

export SECRET_KEY="*/****"

pickapp/pickapp/settings/development.py继承自base.py )中,我已按此方式设置了数据库变量: 发展。

from .base import *

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': get_env_variable('DATABASE_NAME'),
        'USER': get_env_variable('DATABASE_USER'),
        'PASSWORD': get_env_variable('DATABASE_PASSWORD'),
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

# Update database configuration with $DATABASE_URL.
import dj_database_url
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)

我的DJANGO_SETTINGS_MODULE就是这样:

export DJANGO_SETTINGS_MODULE="pickapp.settings.development"

Althought pickapp/pickapp/settings/development.py继承自pickapp/pickapp/settings/base.py SECRET_KEY变量由上述get_env_variable()函数管理

现在,我所描述的所有这些与我的本地开发环境机器有关,我应该告诉Heroku如何找到我的环境变量encypted的值? 我想是的......

关于collectstatic错误

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

我应该在执行collectstatic命令之前执行git push命令吗? 我的静态文件我有他们亚马逊s3

任何关于此的方向将不胜感激。 感谢。

0 个答案:

没有答案