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

Python 将Django部署到Heroku-推送被拒绝,python,django,git,heroku,Python,Django,Git,Heroku,请重定向到此问题的更新2部分:) 我正在尝试将我的Django应用程序部署到heroku,执行git push heroku master命令时出错 你知道我犯这个错误的原因吗 (uleague) ➜ pickapp git:(master) ✗ git push heroku master Counting objects: 195, done. Delta compression using up to 8 threads. Compressing objects: 100% (92/92)

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

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

你知道我犯这个错误的原因吗

(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) ✗
我有以下目录结构:

我遵循,在他们的示例中,requirements.txt和settings.py是根项目中的一个独立文件,而不是作为设置/文件夹或需求/文件夹嵌套在文件夹下

这与我的推送错误有关吗

更新1

我尝试创建一个
requirements.txt
文件,并在其内部创建一行
-r requirements/production.txt

通过这种方式,我的结构目录已保留:

requirements/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\u 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) ✗ 
关于密钥错误

 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\u 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')
export DJANGO_SETTINGS_MODULE="pickapp.settings.development"
这是因为在我的操作系统(virtualenv/bin/postactivate of virtualenvwrapper目录配置)中,我有类似的东西

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\u设置\u模块
是这样的:

# 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')
export DJANGO_SETTINGS_MODULE="pickapp.settings.development"
尽管
pickapp/pickapp/settings/development.py
继承自
pickapp/pickapp/settings/base.py
,其中
SECRET\u KEY
变量由上述my
get\u env\u variable()函数管理

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

关于
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
命令吗? 我的静态文件我在AmazonS3上有它们

任何关于这方面的介绍都将不胜感激。
谢谢。

尝试在project root中创建一个
requirements.txt
,它只包含
-r requirements/production.txt
@v1k45。请看一下我在原始问题中提出的更新1。我不明白dows不起作用的原因…推之前是否运行了
$heroku create--buildpack heroku/python
@v1k45我的错误是在推送之前我没有执行提交操作。很抱歉,现在我遇到了更新2部分中描述的以下情况,以防您需要支持我。谢谢:)确保您的静态文件设置与此配置匹配