Quickly Start a Django Project

There are many things I like to do when starting a django project. I started to compile those in a script I’m using. The gist is linked below.

New Django Project.sh

#!/bin/bash
# 
# Author: Abdallah Deeb 
# Requirements: python, pip, virtualenv, virutalenvwrapper, git
#
# Edit the following 2 lines
PROJECTNAME=proj
APPNAME=myapp
if [ -n "$2" ]
then 
  APPNAME="$2"
fi
if [ -n "$1" ]
then 
  PROJECTNAME=$1
fi

source `which virtualenvwrapper.sh` 

echo "Starting a new Django project: $PROJECTNAME"
# Make a virtualenv
mkvirtualenv $PROJECTNAME

# Install latest django and start the project/app
pip install django
django-admin.py startproject $PROJECTNAME
cd $PROJECTNAME
django-admin.py startapp $APPNAME
mv $PROJECTNAME conf

# conf is much nicer than projname
replace $PROJECTNAME conf -- manage.py conf/settings.py conf/wsgi.py conf/urls.py
chmod +x manage.py
workon $PROJECTNAME

# Initialize and use git
git init
git add .
git commit -a -m 'initial commit'

and the raw gist download

Similar Posts:




No Comments


You can leave the first : )



Leave a Reply

Your email address will not be published.