Skip to content

Instantly share code, notes, and snippets.

@trey
Last active January 27, 2016 22:13
Show Gist options
  • Save trey/2596149 to your computer and use it in GitHub Desktop.
Save trey/2596149 to your computer and use it in GitHub Desktop.
How to start a Django project in 2012

(with Heroku deployment)

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.)

Create a requirements.txt file.

Django
psycopg2
south

(psycopg2 is a PostgreSQL adapter for Python.)

While you're still inside of your virtualenv, load your requirements.

pip install -r requirements.txt

Put south in your INSTALLED_APPS in settings.py.

Now go make something awesome.


Aside: how to update your database with South and push the changes to Heroku:

  1. Make changes to your models
  2. ./manage.py schemamigration [appname] --auto
  3. ./manage.py migrate [appname]
  4. [commit & push changes to heroku]
  5. heroku run ./manage.py migrate [appname]

Sources

@trey
Copy link
Author

trey commented May 26, 2012

This is a Solutions Log post.

@binarymatt
Copy link

why are you install django at the system level and at the virtualenv level?

@trey
Copy link
Author

trey commented Oct 19, 2012

@binarydud, Just for the initial setup of a new project. Not necessary, I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment