To deploy a web app created with Django on heroku
$ git push heroku master
When I executed, the following error occurred.
"""Omission"""
remote:
To https://git.heroku.com/hogehoge.git
![remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/hogehoge.git'
I will write from the conclusion for those who are in a hurry.
** You did not create Procfile, runtime.txt, requirements.txt. ** **
If you're used to it, you might ask, "Is there such a thing?", But there is (crying) I made a mistake in the installation location and it was doubly clogged.
The role of each file and how to create it are explained.
Procfile Role: ** Tell heroku which server you want to use ** Location: ** Install on project root ** (where manage.py is) Contents: Described as follows
web:gunicorn project name.wsgi --log-file -
It means that I will use gunicorn Note that the Procfile has no ** extension **!
runtime.txt Role: Inform heroku of ** Python version ** Location: ** Install on project root ** (where manage.py is) Contents: Described as follows
runtime.txt
python-3.8.5 (3.8.Describe the python version you are using in 5)
requirements.txt Role: ** Tell heroku which library you're using ** Location: ** Install on project root ** (where manage.py is) Contents: Procfile and runtime.txt must be created manually, but requirements.txt does the following in the terminal:
$cd project root directory#To run in the project root directory
$ pip freeze > requirements.txt
This is all you need. Confirm that a text file with a list of libraries is created as shown in the example below.
requirements.txt
"""
Since this is an example, the libraries you are actually using are listed.
"""
appnope==0.1.0
asgiref==3.2.10
backcall==0.2.0
beautifulsoup4==4.9.1
certifi==2020.6.20
chardet==3.0.4
click==7.1.2
coverage==5.2.1
cssselect==1.1.0
decorator==4.4.2
dj-database-url==0.5.0
Django==3.1
.
.
.
"""The following is omitted"""
Of course, the above 3 files are not installed, and even if there is a mistake in the file name or contents, an error will occur, so check carefully.
The site that I used as a reference First web application made with Django (extra edition) heroku deployment
Sites that may be helpful to people in the same situation [Git] What to do when git push is rejected
Recommended Posts