Created
June 7, 2012 15:13
-
-
Save JordanReiter/2889330 to your computer and use it in GitHub Desktop.
Some bash functions that make working with Django && virtualenv a lot easier
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 $* | |
} |
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
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.