How to host Django apps on Heroku

Today Heroku announced their integration with Facebook. Now, with only a few clicks you can have a Facebook application running on Heroku. This sounded interesting so I gave it a try. But while doing it I noticed something unexpected. The environment option of the Heroku hosting dialog showed PHP, Node.js, Ruby and Python. Wait what? Yup, it seems like Heroku can host Python apps. I don’t know if they announced this or not, but this is news for me.

So, I stopped playing with the Facebook integration thing and started working on getting a sample Django running on the service. After a little trial and error I ended with this instructions.

First install RVM and Ruby 1.9.2

Now add RVM to your .bash_profile

Reload your .bash_profile

Now install Ruby 1.9.2 and set it as the defautl

Install the Heroku Gem and set it up

Now lets start by creating a new folder for our app.

Create a virtualenv for new our project and install all the dependencies

Now let’s create a new django app inside our heroku-template folder

Make the executable. This is required by Heroku

Finally create a file called Procfile in the heroku-template folder with the following content

Ok that part is complete now lets put everything on a git repo

Now start the Heroku application using the Cedar stack.


This is how the final folder should look like

That should be it! Happy Hacking.