Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Some bash functions that make working with Django && virtualenv a lot easier
#!/bin/bash
#
# Helper functions for Django projects in virtual env
#
# include in your .bashrc file:
#
# . ~/django_env_functions.sh
#
$MANAGE_PATH = "project/code"
function myenv() {
deactivate
cd /path/to/myenv/
source bin/activate
export DJANGO_SETTINGS_MODULE="settings"
}
function testenv() {
deactivate
cd /path/to/myenv/
source bin/activate
export DJANGO_SETTINGS_MODULE="test_settings"
}
function collectstatic() {
# run collect static for environment & automatically say yes
django-admin.py collectstatic --noinput --settings $DJANGO_SETTINGS_MODULE
}
function dshell() {
# run shell for active environment
django-admin.py shell --settings $DJANGO_SETTINGS_MODULE
}
function dj() {
# run arbitrary django commands
django-admin.py $*
}
@slacy

If you're using Django inside virtualenv, then all your $VIRTUAL_ENV/$MANAGE_PATH/manage.py should really just be $VIRTUAL_ENV/bin/django-admin.py or better yet just django-admin.py since when you're activated, it will already be on your path.

@kennethlove

you can run collectstatic --noinput --settings [...] to not have to use yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.