This is a little out of date. Be sure to check the Heroku docs for the latest and greatest.
First, warm up your system.
$ easy_install pip (may need sudo)
$ pip install virtualenv (may need sudo)
$ pip install django (may need sudo)
$ brew install postgresqlThen be sure to follow the instructions for finishing the postres setup.
Start a project.
$ django-admin.py startproject [myproject]
$ cd !$Setup virtualenv and start it up.
$ virtualenv --no-site-packages ve
$ source ve/bin/activate(ve for virtualenv. Isn't that nice and terse? You can call it whatever you want.)
Install some things into your virtualenv.
$ pip install Django psycopg2 south dj-database-urlNow load the exact version into a requirements.txt file.
$ pip freeze > requirements.txt(psycopg2 is a PostgreSQL adapter for Python.)
Put south in your INSTALLED_APPS in settings.py.
INSTALLED_APPS = (
'south',
...Make .manage.py executable (so you don't have to type python manage.py ... all the time).
$ chmod +x manage.pyDon't forget to add ve to your .gitignore file.
Create a database for local use.
createdb [whatever]Add the following to the end of your settings.py file:
import dj_database_url
DATABASES = {'default': dj_database_url.config(default='postgres://localhost/[whatever]')}If you want to sync your local database with Heroku, see this post.
Now go make something awesome.
$ heroku create
$ git push heroku master
$ heroku run ./manage.py syncdb
$ heroku openUpdate your database with South and push the changes to Heroku
- Make changes to your models
$ ./manage.py schemamigration [appname] --auto$ ./manage.py migrate [appname]- [commit & push changes to heroku]
$ heroku run ./manage.py migrate [appname]
Whenever you work on your project, you'll want to activate your virtualenv:
$ source ve/bin/activateThen load any new requirements:
$ pip install -r requirements.txtSync and/or migrate your database:
$ ./manage.py syncdb
$ ./manage.py migrate [appname]Finally, fire up your server:
$ ./manage.py runserver
This is a Solutions Log post.