Getting Started With Django On Heroku
Here is a set of instructions on how to get a Django app running on Heroku. This assumes you have a repo in github already.
First, create a new app in Heroku and connect the repo to github:
heroku login
heroku git:remote -a <APP_NAME>
Next, you can attach a Postgres database for free executing the following command:
heroku addons:add heroku-postgresql
Next, you need to go back to the Heroku Admin Panel And Create A Database. I am using the dev version so my database is still free.
To tell django about your database, I recommend using the dj-database-url
package. This can be done by inserting the following lines of code into you settings.py
file.
import dj_database_url
DATABASES={}
DATABASES['default'] = dj_database_url.config()
Tailing Heroku Log Files
To tail the current Heroku log files of your app, execute the following command
heroku logs -t
Executing A Django Command
To execute a Django manage.py
command, you can execute the following command
heroku run python manage.py syncdb
Getting to A Bash Shell
You can get to a bash shell pretty easily by executing the following command:
heroku run bash
And you can get to a Python REPL with Django settings by executing the following command:
heroku run python manage.py shell
Copying a File
heroku run 'cp some_file copied_file'