Deploying on Heroku – No more headaches! – Warm up



Deploying on Heroku – No more headaches! – Warm up

1 0


heroku-talk

Short talk about deploying django on heroku

On Github alazaro / heroku-talk

Deploying on Heroku

No more headaches!

Warm up

Start a simple django project.

mkvirtualenv django-sample
pip install django-toolbelt
cd ~/code
django-admin.py startproject sample
cd sample
./manage.py runserver

Some configurations

  • Install Heroku Toolbelt from here
  • Login into Heroku: $ heroku login
  • Add a Procfile

    web: gunicorn sample.wsgi
  • And a requirements file

    pip freeze > requirements.txt

Let's start!

  • Create an account in Heroku.
  • Create an app
$ heroku create dh-django-sample

Adding a database cannot be easier

$ heroku addons:add heroku-postgresql
vim sample/settings.py

# Parse database configuration from $DATABASE_URL
import dj_database_url
DATABASES = {}
DATABASES['default'] =  dj_database_url.config()

Gimme the code!

Create a new repo for your code

git init

Push it!

  • Add a remote to your heroku repo.
  • Commit the code
  • And push it to heroku master!
git remote add heroku git@heroku.com:dh-django-sample.git
git add .
git commit -m 'Initial commit'
git push heroku master

Turn it on!

$ heroku ps:scale web=1

And let the magic flow

THANKS FOR ATTENDING

BY Álvaro Lázaro

More info on Heroku Devcenter