[英]Unrecognised error when deploying django app to heroku with git push
我有一個具有以下文件結構的 django 應用程序
- project_name
(settings, __init__, urls, asgi, wsgi ... *.py)
- manage.py
- app_name
- templates
(template files)
- static
(just some static files)
(urls, views, apps, models __init__ and the other usual files within django app *.py)
- requirements.txt
我認為我已經在頂級目錄(包含 project_name 和 app_name 子目錄)中運行了所有必要的命令
git init
heroku git:remote -a (heroku_app_name)
git add .
git commit -am "this is a commit message"
然后錯誤出現在git push heroku master
,日志如下:
remote: -----> Python app detected
remote: -----> Installing python-3.6.12
remote: -----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: Collecting django
remote: Downloading Django-3.1.3-py3-none-any.whl (7.8 MB)
remote: Collecting django-heroku
remote: Downloading django_heroku-0.3.1-py2.py3-none-any.whl (6.2 kB)
remote: Collecting sqlparse>=0.2.2
remote: Downloading sqlparse-0.4.1-py3-none-any.whl (42 kB)
remote: Collecting asgiref<4,>=3.2.10
remote: Downloading asgiref-3.3.1-py3-none-any.whl (19 kB)
remote: Collecting pytz
remote: Downloading pytz-2020.4-py2.py3-none-any.whl (509 kB)
remote: Collecting whitenoise
remote: Downloading whitenoise-5.2.0-py2.py3-none-any.whl (19 kB)
remote: Collecting psycopg2
remote: Downloading psycopg2-2.8.6.tar.gz (383 kB)
remote: Collecting dj-database-url>=0.5.0
remote: Downloading dj_database_url-0.5.0-py2.py3-none-any.whl (5.5 kB)
remote: Building wheels for collected packages: psycopg2
remote: Building wheel for psycopg2 (setup.py): started
remote: Building wheel for psycopg2 (setup.py): finished with status 'done'
remote: Created wheel for psycopg2: filename=
remote: Stored in directory: /tmp/pip-ephem-wheel-cache-#############
remote: Successfully built psycopg2
remote: Installing collected packages: sqlparse, asgiref, pytz, django, whitenoise, psycopg2, dj-database-url, django-heroku
remote: Successfully installed asgiref-3.3.1 dj-database-url-0.5.0 django-3.1.3 django-heroku-0.3.1 psycopg2-2.8.6 pytz-2020.4 sqlparse-0.4.1 whitenoise-5.2.0
remote: -----> Discovering process types
remote: Procfile declares types -> (none)
remote:
remote: -----> Compressing...
remote: Done: 53M
remote: -----> Launching...
remote:
remote: ! Push failed due to an unrecognized error, and we've been notified.
remote:
remote: ! Please try pushing again.
remote: ! If the problem persists, see http://help.heroku.com/ and provide Request ID ###############
remote:
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to (heroku_app_name).
remote:
To https://git.heroku.com/(heroku_app_name).git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/(heroku_app_name).git'
我決定禁用使用heroku config:set DISABLE_COLLECTSTATIC=1
收集靜態信息,因為它帶來了更多錯誤,但我認為這不是問題所在。
在提出此問題時,我正在運行最新版本的 Windows 10 Home。
您似乎沒有包含 Heroku 部署的Procfile
。 按照以下指南創建Procfile
和設置:
gunicorn
庫,它是 Django 和 Flask 應用程序的生產 Web 服務器pip install gunicorn
gunicorn
添加到您的 requirements.txt 文件中。pip freeze -r requirements.txt
Procfile
的新文件。 這是創建Procfile
后的文件結構:- project_name
(settings, __init__, urls, asgi, wsgi ... *.py)
- manage.py
- app_name
- templates
(template files)
- static
(just some static files)
(urls, views, apps, models __init__ and the other usual files within django app *.py)
- requirements.txt
- Procfile
Procfile
添加到Procfile
:web: gunicorn projectname.wsgi
注意:將projectname.wsgi
行中的“projectname”替換為您的項目名稱
參考: https : //devcenter.heroku.com/articles/django-app-configuration
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.