Last Updated: February 25, 2016
·
393
· bennylope

Aliasing development tasks (e.g. Django dev server)

Identifying environments and paths is annoying, so this snippet makes life easier when developing a Django project and you need to run the dev server, run tests, etc.

This is Puppet code, but the concept can be ported to Chef or Shell scripts.

$bash_profile = "source $venv_path/bin/activate
                cd $app_root/source
                export REUSE_DB=1
                alias runserver='python manage.py runserver 0.0.0.0:8000'
                alias runtests='python manage.py test'"


file { "/home/vagrant/.bash_profile":
    ensure  => present,
    content => "$bash_profile",
}

In this example whenever you log into the Vagrant box you can run the Django development server with runserver and run all project tests with runtests. No fiddling with environments or nothin'.