Awesome
Django Boilerplate is a fast, robust and future-proof base template to get your project off the ground quickly and right-footed.
- Twitter bootstrap (uses LessCSS) and jQuery
- Split settings files for dev/test/prod environments
- South for database migrations
- Caching with Redis and Cache Machine
- Custom template tags, Forms examples, etc.
- django-debug-toolbar
Quick Start
Create a project directory, setup virtualenv, clone the project and setup the dependencies:
# Clone django-boilerplate into project directory
$ git clone git@github.com:metachris/django-boilerplate.git <YOUR_PROJECT_DIR>
$ cd <YOUR_PROJECT_DIR>
# Create and activate virtual env, and install dependencies
$ virtualenv <ENV_DIR>
$ . <ENV_DIR>/bin/activate
$ pip install -r dependencies.txt
# Setting up Twitter Bootstrap
$ git submodule init
$ git submodule update
# Build bootstrap for the first time
$ cd app/static/twitter-bootstrap
$ make bootstrap
Twitter-Bootstrap
Bootstrap is added as a git submodule (into boilerplate/static/twitter-bootstrap
). Make sure you have the LessCSS compiler (lessc
) and uglifyjs
installed for the build toolchain to work. To build bootstrap, execute the following command in boilerplate/static/twitter-bootstrap
:
$ make build
South: Easy Database Schema Migrations
South detects model changes and makes schema migrations extremely easy as well as reversible and documented. It is basically used as a replacement for syncdb
. The South tutorial shows how to easily setup South for an
all new app or converting an existing one.
South with a brand new app
Before any models are created, run syncdb once to add the tables for the apps.
$ python manage.py syncdb
After the initial db setup, store the schema:
$ python manage.py schemamigration <APP_NAME> --initial
South with an existing app
When models are already saved in the database, we need to run syncdb
to add the tables for the
south app, and then convert_to_south <appname>
:
$ python manage.py syncdb
$ python manage.py convert_to_south <APP_NAME>
Schema Migrations
After changing a model we need to create the migration file, and then apply it to update the schema in the database:
# Create migration file
$ ./manage.py schemamigration <APP_NAME> --auto
# Apply migration
$ ./manage.py migrate <APP_NAME>