- https://devcenter.heroku.com/articles/getting-started-with-python#introduction
- postgresql をローカルにインストールする
- https://devcenter.heroku.com/articles/heroku-postgresql#local-setup
- psql にパスを通す
- 起動しておく
- heroku コマンドを準備する
- heroku toolbelt なるものをインストールし、ログインを設定する
- サンプルプロジェクトを clone してくる
git clone https://github.com/heroku/python-getting-started.git
- レポジトリ内で、
heroku create [<name>]
するhttp://<name>.herokuapp.com/
という URL でアプリを作成する- レポジトリの remote に
heroku
という名前でhttps://git.heroku.com/<name>.git
というレポジトリを登録する - 省略すると適当な名前がつく
- アプリがちゃんと動いてるようにする
heroku ps:scale web=1
- あんまりちゃんとわかってない
- アプリを開く
heroku open
すると簡単に開ける
- ログを見る
heroku logs --tail
- アクセスないと自動で落ちるっぽいらしい
- 後述
Procfile
になんか走るコマンド的なものが書いてある- dyno
- heroku ps で見れる
- https://devcenter.heroku.com/articles/getting-started-with-python#scale-the-app
- 30 分アクセスがないとスリープに入る
- アクセスがあると起きる
requirements.txt
の存在を見て python プログラムだと分かるらしい- アドオン入れる
- https://devcenter.heroku.com/articles/getting-started-with-python#provision-add-ons
heroku addons:create papertrail
したらクレカの番号入れろって言われたのでとりあえず飛ばし
- コンソールに入る
heroku run python manage.py shell
- アプリが動いてるのと同じ環境で python が動く
- heroku run bash
- dyno に ssh してる?
- config vars
- 環境変数として扱える
- ローカルで動かしているときは、
.env
に入れる - リモートに設定したい場合
heroku config:set TIMES=2
する - リモートの設定は
heroku config
で見れる
- データベースの設定をする
- https://devcenter.heroku.com/articles/getting-started-with-python#provision-a-database
- heroku pg でデータベースの情報が見れる(なんの略だ?)
- この hobby-dev プランの説明をちゃんとわかってない
- /db にアクセスすると見れるけど、エラーを吐く
heroku run python manage.py migrate
でテーブルとか作る- /db にアクセスするとアクセスが見れるようになる
heroku pg:psql
でリモートのデータベースに接続してクエリ発行できる
-
-
Save 10sr/cf8b84cf16f2e67f5dac to your computer and use it in GitHub Desktop.
django heroku アプリつくる
ローカルの開発環境
- virtualenv を使う
- https://devcenter.heroku.com/articles/getting-started-with-python#declare-app-dependencies
- しょうじきあんまりわかってない
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt --allow-all-external
- ローカルで動かすための準備
python manage.py collectstatic
foreman start web
- localhost:5000 で動く
- よくわかってない…
- とりあえず後回し
- データベースの設定
createdb python_getting_started
foreman run python manage.py migrate
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://devcenter.heroku.com/articles/how-heroku-works
https://devcenter.heroku.com/categories/python
ココらへんも見るとよい