fabric-deploy-django / README.txt


Easily reusable fabfile that can be used with the fabric application 
to quickly deploy a Django project using Apache, mod_wsgi, virtualenv 
and pip.


You will need to have fabric installed to use this fabfile. Install it
it like so:

$ sudo pip install fabric

It was written for Python 2.6+

If you use a Python version less than 2.6 then please refer to this 

You will need to add the following to your

from __future__ import with_statement


Simply copy the to the root of your project directory and 
edit the to fit your project.

Project structure should look like so:



Edit the following globals:

env.project_name = 'PROJECT_NAME'

This is the name the project (ie, "myproject" above in the structure example)

env.run_south_migrate = True

Run 'python migrate' after syncdb is run.

env.copy_base_settings_local = False

If true, the script will look for a file named myproject/
and copy it to myproject/

env.num_releases = 7

The number of old releases to leave on the deploy destination.

Edit the 3 deploy defining functions in the fabfile (local, staging, prod):

env.hosts = ['localhost']

Host(s) that the commands should be run on

env.path = '/path/to/envs/myproject'

Path for this project to be deployed to.

env.user = 'yourusername'

The username to run the commands as

env.run_type = 'local'

If this is set to 'local' then the internal function _is_local() will evaluate 
to True. This means that the deploy is actually being run on the LOCAL machine.
This is mostly used for testing the deploy process. Anything other than 
'local' will mean that the deploy will be run on whatever hosts are set in 

env.repo_path = '/path/to/local/repo/myproject'

Path (local FS or URL) to the repository to clone (or pull from) during the 

env.repo_rev = 'tip'

The revision to use when pulling/cloning from the repository 
(set in env.repo_path above) 


Here is a basic deploy to the LOCAL machine:

$ fab local setup

Or say to the production environment:

$ fab prod setup

Create a more through install and use docs.

Auto import __future__ if using Python < 2.6

Make various functions more loosely coupled to the tools currently.
(ie, easy to switch from deploying with hg to git or svn, etc.)

Copyright & Warranty
All documentation, libraries, and sample code are 
Copyright 2010 Peter Sanchez <>. The library and 
sample code are made available to you under the terms of the BSD license 
which is contained in the included file, BSD-LICENSE.