我想在 Heroku 上部署一个 Django 应用程序,但出现错误
Posted
技术标签:
【中文标题】我想在 Heroku 上部署一个 Django 应用程序,但出现错误【英文标题】:I want to deploy a Django app on Heroku, but I got error 【发布时间】:2021-06-05 22:31:19 【问题描述】:我想在 Heroku 上部署一个 Django 应用。
开发环境是wsl(debian),python3.9.0,虚拟环境是“venv”。
我在这里提到:https://tutorial-extensions.djangogirls.org/ja/heroku/
在此代码之前完成:git push heroku master
运行git push heroku master
,
然后我收到以下错误:
(env) me@Ver:~/docker_heroku/djangogirls210307$ git push heroku master
Enumerating objects: 78, done.
Counting objects: 100% (78/78), done.
Delta compression using up to 4 threads
Compressing objects: 100% (64/64), done.
Writing objects: 100% (78/78), 25.08 KiB | 885.00 KiB/s, done.
Total 78 (delta 18), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: ! No default language could be detected for this app.
remote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote: See https://devcenter.heroku.com/articles/buildpacks
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: ad15f239126a3588a2ab6585b0ae52bfa25d9b7e
remote: !
remote: ! We have detected that you have triggered a build from source code with version ad15f239126a3588a2ab6585b0ae52bfa25d9b7e
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run:
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to django-210307.
remote:
To https://git.heroku.com/django-210307.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/django-210307.git'
我已经运行heroku create
,
"djangogirls210307" 已在 heroku 上创建。
下面的输出是用heroku info --app diangogirls210307
得到的信息
=== djangogirls210307
Auto Cert Mgmt: false
Dynos:
Git URL: https://git.heroku.com/djangogirls210307.git
Owner: mailme@gmail.com
Region: us
Repo Size: 0 B
Slug Size: 0 B
Stack: heroku-20
Web URL: https://djangogirls210307.herokuapp.com/
我还将工作目录命名为“djangogirls210307”并在其中使用以下结构。
djangogirls210307/
|
|- env // by "venv", not "virtualenv""pipenv"
|-mysite // name of project
|-__init__.py
|-asgi.py
|-local_settings.py
|-urls.py
|-settings.py
|-wsgi.py
|-.gitignore
|-manage.py
|-Procfile
|-requirements.txt
|-runtime.txt
报错中显示'django-210307.git',但很可能是今天练习时创建的远程仓库。
所以,我想问以下问题。感谢您的合作。
-
我想知道部署成功完成之前的过程。
我想知道是否可以通过更改推送目的地来解决。
但是,我不明白为什么使用
git push heroku master
命令修复了推送目标。
我想知道如何更改和指定推送目的地。
如果您不介意在问题中使用了错误的词,请告诉我。
【问题讨论】:
附注我通过heroku login --interactive
登录了 Heroku,因为我在 WSL/Debian 中没有 Web 浏览器,heroku login
命令将无法登录。
【参考方案1】:
remote: -----> Building on the Heroku-20 stack
remote: ! No default language could be detected for this app.
remote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote: See https://devcenter.heroku.com/articles/buildpacks
手动设置构建包:
heroku buildpacks:set heroku/python
【讨论】:
谢谢,锡。在git push heroku master
之前,我应该指挥它heroku buildpachs...
,对吧?以上是关于我想在 Heroku 上部署一个 Django 应用程序,但出现错误的主要内容,如果未能解决你的问题,请参考以下文章
Django:使用 sqlite3 作为数据库在 Heroku 上部署应用程序