Created
July 11, 2016 10:34
-
-
Save govindpatel/ad22d37a1babe3a5aff69679eae2f705 to your computer and use it in GitHub Desktop.
Create a django environment
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 | |
# this script will do the following | |
# create a folder by the name provided in argument1 | |
# create a new virtualenv inside that folder | |
# activate the environment and using pip to install django | |
# start a django project by the name provided in argument2 | |
# do the db migrate using python manage.py migrate | |
# and atlast, deactivate the environment | |
# to run this file use "sh django-script.sh outer-folder-name django-project-folder-name" command. | |
# location of environment "outer-folder-name/env" | |
# location of django project folder "outer-folder-name/django-project-folder-name" | |
echo "Folder name: $1" | |
echo "proj name: $2" | |
# check if both arguments are present or not | |
if [ -z "$1" ] || [ -z "$2" ] | |
then | |
# one or both argument are missing | |
echo "Not creating anything" | |
else | |
# both argument are present | |
echo "Creating the env and folder" | |
mkdir $1 | |
cd $1 | |
# creating a virtual env in $1 | |
virtualenv env | |
# activate the environment | |
source env/bin/activate | |
# install django | |
pip install Django==1.8 | |
# start the project | |
django-admin startproject $2 | |
cd $2 | |
# migrate db | |
python manage.py migrate | |
#deativate env | |
deactivate | |
echo "Done creating the env and folder" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment