Django project layout for Heroku
At Blimp we love working with Django. We use it for almost all of our projects, including Blimp and -M.
In Django 1.4, the startproject and startapp commands came with a new template option. Specifying this --template option lets you use a custom project directory structure for your project from a path or URL. By default when you run the startproject management command, it creates a Django project directory structure that contains manage.py and a project package (containing a settings.py and other files) based on this default template.
We decided to create a project template with the things we always end up doing on our Django projects. This template has a couple of useful settings and Fabric commands that make deploying, managing, and using Django with Heroku easier.
How to install
django-admin.py startproject --template=http://git.io/2h-ygQ --extension=py,md,dev project_name
What’s included?
- Fabric - Fabric is a Python library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks.
- South - schema and data migrations for Django
- dj-database-url - Django utility allows you to utilize the DATABASE_URL environment variable to configure your Django application.
- django-extensions - Custom management extensions for the Django
- gunicorn - Simply implemented, light on server resource usage, and fairly speedy Python WSGI HTTP Server.
- psycopg2 - PostgreSQL database adapter for Python
Fabric Script
Fabric is definitely the easiest way to execute local and remote shell commands. We’ve created quite a few of these to help with deployment, database management, and Heroku, all aware of the environment, so for example, you can easily run database migrations in development, staging, or production.
