LoginSignup
10
12

More than 5 years have passed since last update.

Webアプリ開発実践:Djangoでシフト作成ページを作ろう!(herokuで公開・実験編)

Last updated at Posted at 2014-07-21

とりあえず現時点での状態をHerokuで公開しておくことにしました。こんな感じ(未実装の部分もかなり残っていますがあしからず)。

公開用アカウント(name:hoge,pass:hogehoge)

ちょっとソースコードが訳分からなくなったりしてきたので、これはひとまず本番前の勉強だったということにして改めて作り直すことにしました(随時投稿するつもり)。

-

Herokuで公開するまでの流れ

主に自分の過去の投稿を参考に進めたのだが、なんだかその時とは違った現象が起こったりしたので記録しておく。

まずは Procfile を書いたり requirements.txt を用意したりして準備。

Procfile
web: gunicorn shift_maker.wsgi

以前はこの書き方だと上手くいかなかったのだが以下を参考に wsgi.py を編集したら普通にできた(コメントのところにある sys.path.append を加える)。
http://qiita.com/juniskw/items/b9278557daf471a89205

あとはチュートリアルに沿って進めていく。 settings.pywsgi.py も微妙にHeroku用の編集が必要なので要注意。それからforeman startを実行してちゃんと動くかテスト・・・うん、大丈夫そうだ。

そしていよいよheroku create。ここでも特にエラーは出ない。

じゃあ見てみようということでheroku ps:scale web=1すると・・・

Scaling dynos... failed
! No app specified.
! Run this command from an app folder or specify which app to use with --app APP.

あれ?という感じ。アプリ名を指定して再挑戦。

heroku ps:scale web=1 --app my-app-0001

Scaling dynos... failed
! App must be deployed before dynos can be scaled.

ちょっと変わった。
ここで「あ、そういえばまだpushしてない」と思いgit push heroku master
だが今度は・・・・

fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

ということで上手くいかない。「前はこんなことしなかったと思うんだけどなあ」と思いつつも

git remote add heroku git@heroku.com:my-app-0001.git

これを実行し、git push heroku master。すると今度は上手くいった、と思いきや・・・・

! Push rejected, no Cedar-supported app detected

To git@heroku.com:my-app-0001.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:my-app-0001.git'

何だろうかこれは?Cedar?
ということでググる。以下のページがドンピシャだったので参考にさせていただいたところ上手くいった。
http://tkoyama1988.hatenablog.com/entry/2013/12/13/072150

あとは試しにアクセスしてみたときにログインページで見覚えのないエラーが出て一瞬パニックになったが、要はデータベースを構築していなかっただけ。

heroku run python manage.py syncdb

これでOK。

10
12
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
10
12