#Brew & Postgress Install
Mac:
Terminal:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install postgresql
Ubuntu:
https://help.ubuntu.com/community/PostgreSQL
Notes:
http://brew.sh/ http://braumeister.org/formula/postgresql
#Create Heroku account
Go to http://heroku.com and get a free account.
#Install Heroku Toolbelt
Download the heroku toolbelt and install:
Run the package file.
#Create Virtual Environment
In the directory where manage.py lives run:
sudo pip install virtualenv
virtualenv venv
source venv/bin/activate
pip install gunicorn pip install dj-database-url
Pip install any modules that you need ex: requests ex: BeautifulSoup
#Create Procfile
Create a file called Procfile with upper case P in the same directory with manage.py
put the line below in that file
web: gunicorn django project name.wsgi --log-file -
#Install all pip requirements
Install any pip modules you need
pip freeze > requirements.txt
#Settings changes
Update the /settings.py file based on the link below under Django Settings
Place at the bottom of settings.py
import dj_database_url
if os.environ.has_key('DATABASE_URL') and dj_database_url.config():
DATABASES['default'] = dj_database_url.config()
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'), )
Notes: https://devcenter.heroku.com/articles/getting-started-with-django#django-settings
#Update wsgi
Update /wsgi.py per the instructions
from django.core.wsgi import get_wsgi_application
from dj_static import Cling
application = Cling(get_wsgi_application())
Note: this line replaces application = get_wsgi_application()
#Create new Heroku app
heroku create
#Push code to Heroku
git push heroku master
#Setting Environment variables
Environment variables locally
Using it in Django settings.py
in settings.py - using env var
import os
SECRET_KEY = os.environ.get('SECRET_KEY')
Setting environment var in the shell/terminal
export SECRET_KEY=myawesomekey env
#Setting Enviornement Variables on Heroku
heroku config:set SECRET_KEY=8N029N81 S3_SECRET=9s83109d3+583493
Notes: https://devcenter.heroku.com/articles/config-vars
#Run Migration on heroku
First add basic postgres on heroku site
heroku run python manage.py migrate
#Create admin user
create an admin super user
heroku run python manage.py createsuperuser
#Create new secret key