到 https://www.heroku.com/ 註冊
下載 heroku cli https://devcenter.heroku.com/articles/heroku-cli#download-and-install
到 git 官網下載 https://git-scm.com/downloads
建立 requirement.txt 讓 heroku 依照 requirement.txt 安裝套件。
進入 Python 虛礙環境,到專案資料夾,找專案中的原來requirement.txt,將原來的requirement.txt改名,再將使用到的套件列出至 requirement.txt。
Procfile 設定檔是設定 heroku 啟動網站的方式
在專案中 manage.py 的目錄中,建立 Procfile
通常正式上線(production)時的環境會和開發時所做的settings.py設定有所不同,我們希望網站上線時使用一個全新的、空白的資料庫。
另外建立一個production_settings.py,放在原本的settings.py旁邊
我們不希望把有些開發時使用的檔案,例如虛擬環境、本機資料庫等等。因此,接下來需要建立一個 .gitignore 檔案,排除這些資料:
在 cli 上登入 heroku,登入剛註冊的帳號
Heroku 使用 Git 管理專案。當我們想把專案上傳到 Heroku 時,必須使用 git push 指令,把專案 push 上去。
現在 heroku 資料庫是全新的,要先同步及建立superuser
開啟網頁
在修改完網站內容後,一樣要透過 git 來更新