Getting Start with Django/PostgreSQL on Heroku


Heroku is a powerful cloud application platform. It provides everything you need to build, run, and scale. Heroku supports Ruby, Node.js, Python, Java, and PHP so you can use the languages you already know to build and deploy apps on Heroku.

Aha, let's start:

  1. Install the heroku-toolbelt, it's very convenient to when you are using Heroku, well, dont install heroku-toolbelt by brew, because by this you wont install foreman at the same time.

  2. Write a useful requirements.txt, that's what make sure that your projects can run well on Heroku server, there are some modules you must add in that file:

     Django (haha, you should have this)
  3. for your django settings.

     DATABASES['default'] =  dj_database_url.config()
     # set Database info on Heroku server
     STATIC_ROOT = 'staticfiles'
     STATIC_URL = '/static/'
     STATICFILES_DIRS = (os.path.join(BASE_DIR, '../static'),)
     #set where to store the static files

    if you wanna use DEBUG mode in Django, add a config like HEROKU_ENV on Heroku to turn DEBUG on/off at online/offline. Add that like this "heroku set:config HEROKU_ENV=TRUE

  4. After git push heroku master, dont forget to set your database

     heroku run python syncdb
     heroku run python migrate(if with south&tastypie)
  5. Aha, the last step "heroku open"! see your website welcome page!