有一些关于此特定问题的帖子,但是我尝试了与这些帖子有关的五到六个不同建议,但没有运气。
尝试时
git push heroku master
我收到以下错误:
(env) PS C:\Users\Shaun\Desktop\DjangoBlog\src> git push heroku master
Total 0 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to murmuring-dusk-96030.
remote:
To https://git.heroku.com/murmuring-dusk-96030.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/murmuring-dusk-96030.git'
在Heroku网站上的构建日志中:
-----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
! Push failed
我有一个简单的静态网站,以Django 2.2.3作为后端。我一直在本地计算机上的虚拟环境中进行开发,并且显示了以下项目结构,其中src/
是我通过django-admin startproject命令重命名的文件夹的名称。
我想在Heroku上部署我的网站,所以我已经注册,安装了Git和Heroku CLI。在我的终端中,我登录到Heroku并在此顶级根(src/
)中初始化了Git存储库。我添加了一个Procfile
,其中包含以下内容:
web: gunicorn blog.wsgi --log-file -
我的runtime.txt
文件中包含以下内容。我实际上在虚拟环境中运行3.7.3,但是我尝试了两种方式:
python-3.6.1
对于我添加的设置:
import django_heroku
MIDDLEWARE = [
# added this:
'whitenoise.middleware.WhiteNoiseMiddleware',
]
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
# Add configuration for static files storage using whitenoise
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
django_heroku.settings(locals())
我的requirements.txt
包含我正在使用的所有软件包以及psycopg2
,whitenoise
和gunicorn
,django-heroku
。
我不确定我到底在做什么错,会有所帮助。
答案 0 :(得分:2)
您的requirements.txt
以及您的Procfile
和runtime.txt
,must be in the top-level root directory of your project。
将其移动到此处,提交更改,然后再次部署,例如
cd $PROJECT_ROOT
git mv src/requirements.txt .
git mv src/Procfile .
git mv src/runtime.txt .
git commit -m 'Move requirements.txt and Heroku files to root'
git push heroku master