Skip to content

Instantly share code, notes, and snippets.

@selenamarie
Created August 11, 2012 17:48
Show Gist options
  • Save selenamarie/3325969 to your computer and use it in GitHub Desktop.
Save selenamarie/3325969 to your computer and use it in GitHub Desktop.
create a new django project
# Setting up a new django project
PROJECT='newproject'
PROJECTDBUSER='newproject_www'
NEWAPP='newapp'
virtualenv ~/venv/$PROJECT
source ~/venv/$PROJECT/bin/activate
pip install django
pip install psycopg2
cd ~/proj/repos
django-admin.py startproject $PROJECT
# Create database
psql postgres -e "create user $PROJECTDBUSER superuser login"
psql -U $PROJECTDBUSER postgres -e "create database $PROJECT"
# EDIT settings.py to include all that stuff
cd ~/proj/repos/$PROJECT
cat >> settings.py <<EOF
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '$PROJECT', # Or path to database file if using sqlite3.
'USER': '$PROJECTDBUSER', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
EOF
cd ~/proj/repos/$PROJECT
chmod 755 manage.py
python manage.py syncdb
python manage.py startapp $NEWAPP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment