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.

4 thoughts on “How to host Django apps on Heroku”

  1. May I recommend this rather than rvm (a complete waste if you don’t normally work with Ruby):

    This gist provides hooks for virtualenv to create a “virtualenv” for gems every time you activate/deactivate. Very simple scoping for cheap.

    This isn’t mine, but Carl May’s code. I just pass it on as it is, imo, the best way to handle Heroku (and Sass for example).

    Also, you should add Gunicorn to the requirements, will handle traffic better. :)

    1. My virtualenv directory is on ~/.virtualenvs//. The confusion might be that I ran the mkvirtualenv command in the root of the project. But in my current setup virtualenvs always are created under ~/.virtualenvs/.

Leave a Reply