Sunday, May 27, 2012

Getting Started with Django on Heroku

There's a pretty good guide about how to set up django on Heroku here. However, the prerequisites that are mentioned can be a bit tricky to figure out, the sample application isn't all that good, and there are a few confusing steps. This is my attempt at fixing all of this.

Prerequisites (Modified)

To follow this tutorial, you will need

Local Notes Application Setup

Make a new folder called web in your home directory and go into it
$ cd ~
$ mkdir web
$ cd web
Checkout the notes application from git
$ git clone git@github.com:theicfire/heroku-django-notes.git
Go into the newly created directory and activate the environment:
$ cd heroku-django-notes
$ source venv/bin/activate
Change the database credentials by modifying the following line in main/settings.py to your Postgresql password
'PASSWORD': 'yourpass',                  # Not used with sqlite3.
Run the server:
$ foreman start
Go to localhost:5000 to make sure everything is working.

Deploy to Heroku

Go to the Heroku Django Tutorial and follow this instructions under "Deploy to Heroku"

Done

You should now be done with a fully functioning notes application, deployed on Heroku!

Notes and Troubleshooting

If you can't connect to database, make sure it's running and that the port in your settings.py file is correct:
$ grep postgresql /etc/services
postgresql      5432/tcp        postgres        # PostgreSQL Database
postgresql      5432/udp        postgres
The above output means that Posgresql is running on port 5432. Make sure this is consistent with that in your main/settings.py file.

No comments:

Post a Comment