LoginSignup
9
9

More than 5 years have passed since last update.

HerokuへデプロイしてDjangoを動かす。

Posted at

開発環境

Python3.5.1
Django1.9.6
PyCharm

プロジェクトの準備

Pycharmで、Djangoプロジェクトを生成する。
そのままのプロジェクト構成では、Herokuへデプロイしても動作しないので、下記のファイルを配置してHerokuで認識できるようにする。

Herokuで必要なファイル

runtime.txt
python-3.5.1

gunicornというPython用のWSGI HTTP Serverを必要とするのでインストールするように記述する。

requirements.txt
Django==1.9.6
gunicorn==19.5.0

プロジェクトのアプリケーション作成した時に生成されたsetting.pyの中に記述された下記のアプリケーション名をProcfileに合わせて記述する。
WSGI_APPLICATION = 'myapp.wsgi.application'

web: gunicorn myapp.wsgi --log-file -

Gitリポジトリの設定

$ heroku login

$ cd myapp/
$ git init
$ heroku git:remote -a myapp

Herokuへデプロイ

$ git add .
$ git commit -am "Init my Project"
$ git push heroku master

これで、Herokuで動作するはず。

9
9
0

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
9
9