Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
72 lines (53 sloc) 2 KB


Common methods to help create fabric deplopment scripts for django

The idea is to allow you to use a that has just the unique things for your specific project, while taking advantage of common functions for version control and django tasks.

You can also move configuration out of the into ini style configuration files.


sudo easy_install django-fab
sudo easy_install

git example

from djangofab.api import *
from django.conf import settings
from djangofab.vcs.git import update_remote, update_local, push, commit, add
env.capture_default = False

# apply the settings from fab.cfg default section
# sets DJANGO_SETTINGS which allows access to django.conf.settings values

#use the default section of fab.cfg
def prod():
    "Production settings"
    env.hosts = ['server1']
    env.path = '%(prod_path)s'
    env.giturl = '%(giturl)s'
    env.site_user = 'owner'
    env.site_group = 'group'

def dev():
    "Development settings"
    env.hosts = ['server1']
    env.path = '%(dev_path)s'
    env.giturl = '%(giturl)s'
    env.site_user = 'owner'
    env.site_group = 'group'

#use the local section
def localhost():
    "Local settings"
    env.path = '%(dev_path)s'
    env.giturl = '%(giturl)s'

def deploy():
    "Push local changes and update checkout on the remote host"
    update_remote() # reset and pull on the remote server

def test():
    print "website using database %s " % (settings.DATABASE_NAME,)

Requries fabric>=0.9

See fabric docs