- 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 venvsource venv/bin/activatepip install -r requirements.txt --allow-all-external
- ローカルで動かすための準備
python manage.py collectstaticforeman start web- localhost:5000 で動く
- よくわかってない…
- とりあえず後回し
- データベースの設定
createdb python_getting_startedforeman run python manage.py migrate
Author
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
ココらへんも見るとよい