LoginSignup
4

More than 3 years have passed since last update.

heroku デプロイメモ(Django)

Last updated at Posted at 2020-06-27

Djangoの準備

詳細はWorking with Djangoを参照

Procfile

Procfileを作成し下記を追加。

Procfile
web: gunicorn PROJECTNAME.wsgi

settings.py

django-herokuをインストールする

pip install django-heroku

settings.pyに下記を追加

settings.py
import django_heroku
django_heroku.settings(locals())

requirements.txt

ルートディレクトリ(プロジェクトフォルダ配下)に、requirements.txtを作成し以下を追加

requirements.txt
django
gunicorn
django-heroku

※事前にPostgreSQLがインストール済みであること。(Macの場合は、brew install

herokuの準備

herokuにログイン

heroku login

アプリケーションの作成

heroku create APPNAME

gitの設定

heroku git:remote -a APPNAME

buildpacksの設定

heroku buildpacks:set heroku/python 

デプロイ

デプロイ

git push heroku master

アプリケーション起動

heroku open

その他

heroku上でコマンド実行

heroku run COMMAND

コマンドの中断: heroku run:detached COMMAND

ログ

heroku logs --t

アプリケーションの一覧

heroku list

アプリケーション毎のコマンド実行

heroku COMMAND --app APPNAME

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4