Created
October 27, 2012 10:11
-
-
Save pixyj/3963953 to your computer and use it in GitHub Desktop.
Script to create django project with virtualenv
This file contains 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 | |
#Take project name as input | |
if [ -z "$1" ] | |
then | |
echo "Enter project name" | |
read proj | |
else | |
proj="$1" | |
fi | |
#Create a virtualenv | |
virtualenv $proj | |
cd $proj | |
source bin/activate | |
#Install django within the virtualenv | |
echo "PIP_RESPECT_VIRTUALENV=true" >> bin/activate | |
touch requirements.txt | |
echo "django" >> requirements.txt | |
pip install -r requirements.txt | |
#Create project | |
python lib/python2.7/site-packages/django/bin/django-admin.py startproject $proj | |
#Set default environment variables | |
export DJANGO_SETTINGS_MODULE="$proj.settings" | |
export PYTHONPATH="$VIRTUAL_ENV/$proj" | |
#Write the variables into activate for future use. | |
echo "export DJANGO_SETTINGS_MODULE=$proj.settings" >> bin/activate | |
echo "export PYTHONPATH=$VIRTUAL_ENV/$proj" >> bin/activate | |
#Reset virtualenv and we are ready | |
deactivate | |
source bin/activate |
Oops, missed out one more command
$ chmod +x django_one_step.sh
$ ./django_one_step.sh your_project
$ source bin/activate
OK, hopefully final change to usage. Now it's truly one-step.
$ source django_one_step.sh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
$ chmod +x django_one_step.sh
$ ./django_one_step.sh your_project
http://intendindent.blogspot.in/2012/10/script-to-create-django-project-with.html