• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Building a Django App on Heroku
 

Building a Django App on Heroku

on

  • 273 views

A quick overview on how to build a Django app on the Heroku platform

A quick overview on how to build a Django app on the Heroku platform

Statistics

Views

Total Views
273
Views on SlideShare
261
Embed Views
12

Actions

Likes
0
Downloads
3
Comments
0

4 Embeds 12

http://www.slideee.com 6
http://localhost 4
https://twitter.com 1
http://eventifier.co 1

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Building a Django App on Heroku Building a Django App on Heroku Presentation Transcript

    • Building a Django App on Heroku Get your project up and running in 20 minutes or less.
    • What is Heroku? ● Platform-as-a-Service (PaaS) ● Acquired by salesforce.com in 2010
    • Why Heroku? ● ● ● ● Focus on developer productivity 100% free plan includes hosting & db No need to think about servers Easily scales
    • Why we chose Heroku ● Free to start ● No bandwidth/budget for devops ● Flexibility to deploy elsewhere in future if needed
    • Prerequisites Familiarity with: ● command line ● git
    • Prerequisites Install: ● pip http://www.pip-installer.org ● Postgres pip install psycopg2 http://initd.org/psycopg/
    • Prerequisites Install: ● Virtualenv pip install virtualenv
    • Getting Started 1. Sign up for a Heroku account at Heroku.com 2. Install Heroku Toolbelt: https://toolbelt.heroku.com 3. Log in via command line
    • Create a Django app locally $ $ $ $ $ mkdir mysite && cd mysite virtualenv venv --distribute source venv/bin/activate pip install django-toolbelt django-admin.py startproject mysite .
    • Create a Procfile Create a Procfile in your root project directory: # Procfile web: gunicorn hellodjango.wsgi
    • Create requirements.txt $ pip freeze > requirements.txt Note: If you do this out of order, you’ll need to manually create requirements.txt
    • Modify settings.py import dj_database_url DATABASES['default'] = dj_database_url.config() SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') ALLOWED_HOSTS = ['*'] # Static asset configuration import os BASE_DIR = os.path.dirname(os.path.abspath(__file__)) STATIC_ROOT = 'staticfiles' STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), )
    • Modify wsgi.py from django.core.wsgi import get_wsgi_application from dj_static import Cling application = Cling(get_wsgi_application())
    • Store your app in git First create a .gitignore file; add: venv *.pyc staticfiles
    • Store your app in git Initialize a new git repository $ git init Add the new files $ git add . Commit your files $ git commit -m "initial commit"
    • Push your code to Heroku Create a new app on Heroku $ heroku create Deploy your code to Heroku $ git push heroku master
    • Start your app Each Heroku app comes with 1 free dyno. Start a Heroku dyno $ heroku ps:scale web=1 Scaling dynos... done, now running web at 1:1X. Terminology: Dynos are isolated, virtualized Unix containers, that provide the environment required to run an application.
    • Visit your app $ heroku open
    • Visit your app Congrats! You’ve set up a live Djangopowered application via Heroku.