First, warm up your system.
$ easy_install pip
$ pip install virtualenv
$ pip install django
$ gem install heroku
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
Now 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',
...
Setup SQLite for local development. Also in settings.py
:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'development.sqlite',
...
Make .manage.py
executable (so you don't have to type python manage.py ...
all the time).
$ chmod +x manage.py
Don't forget to add ve
to your .gitignore
file.
Now go make something awesome.
$ heroku create --stack cedar
$ git push heroku master
$ heroku run python manage.py syncdb
$ heroku open
Update 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/activate
Then load any new requirements:
$ pip install -r requirements.txt
Sync and/or migrate your database:
$ ./manage.py syncdb
$ ./manage.py migrate [appname]
Finally, fire up your server:
$ ./manage.py runserver