Skip to content

Deploy to Heroku steps

Ana Sustic edited this page Mar 9, 2015 · 10 revisions

requirements.txt:

Django==1.7.1
Pillow==2.7.0
PyJWT==0.4.1
argparse==1.2.1
dj-database-url==0.3.0
dj-static==0.0.6
gunicorn==19.3.0
oauthlib==0.7.2
python-openid==2.2.5
python-social-auth==0.2.1
requests==2.5.1
requests-oauthlib==0.4.2
six==1.9.0
whitenoise==1.0.6
wsgiref==0.1.2
psycopg2==2.5.4

Procfile

web: gunicorn mysite.wsgi

runtime.txt

python-2.7.6

settings_local.py

from settings import *

SOCIAL_AUTH_GITHUB_KEY = 'blabla'
SOCIAL_AUTH_GITHUB_SECRET = 'blabla'

import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))

DATABASES = {
   'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

DEBUG = True


DEBUG = True

settings.py

(added at the end of the file)

import dj_database_url
DATABASES['default'] =  dj_database_url.config()

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

ALLOWED_HOSTS = ['*']

STATIC_ROOT = 'staticfiles'

DEBUG = False

urls.py

(added at the end of the file)

if not settings.DEBUG:
    urlpatterns += patterns('',
        (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
    )

wsgi.py

(added at the end of the file)

from whitenoise.django import DjangoWhiteNoise
application = DjangoWhiteNoise(application)
import django.core.handlers.wsgi  
application = django.core.handlers.wsgi.WSGIHandler()

.gitignore

(added at the end of the file)

env
db.sqlite3

In virtual environment:

git config user.name "TrackCat"
git config user.email "[email protected]"
git add -A .
git commit -m "TrackCat app"
heroku create trackcat
git push heroku master
heroku ps:scale web=1
heroku open

heroku run python manage.py migrate
heroku run python manage.py createsuperuser