/django-project-template

Django 1.6+ project template layout.

Primary LanguagePython

django-project-template

At Blimp, we love working with Django. For every project we start we always ended up doing the same thing. Installing Django, setting up environment settings, installing South, etc... So I decided to take all of that and create a Django Project Template to use with the startproject command new in Django 1.6. This template has a couple of useful settings and Fabric commands that make deploying, managing, and using Django with Heroku easier.

Getting Started

Always good to work in a virtualenv

$ virtualenv env
$ cd env
$ source bin/activate

Install it!

$ django-admin.py startproject --template=https://github.com/askedrelic/django-project-template/zipball/master --extension=py,md,dev project_name

Apps included

Fabric
South
dj-database-url
django-extensions
gunicorn
psycopg2

Settings

The manage.py script checks for an environment variable called ENVIRONMENT with values of STAGING or PRODUCTION. If none of those are found, development environment is assumed. We use this to automatically set DJANGO_SETTINGS_MODULE. This makes using manage.py easier because you dont have to keep remembering of writing --setting=project.settings.development. We converted settings.py into a module with settings splitted into three different files, development.py, staging.py, production.py. All of those import common settings from common.py and override them or set new ones depending on the environment.

Fabric Script

Environments

fab development 'command'
fab staging 'command'
fab production 'command'

Deployment

fab production deploy
fab production collectstatic
fab brunchwatch
fab brunchbuild

DB

fab staging resetdb
fab schemamigration
fab migrate
fab updatedb

Heroku

fab production ps
fab production restart
fab production tail
fab production shell
fab production config