As I am learning Django, I started writing the instructions (from the
great tutorials) in a simplified form.

It became a bash script (which is really weird since I'm not a great
bash programmer).

I am including it in case it helps anyone or anyone has ideas on how to
improve it:

#!/bin/bash

PROJECT_CONTAINER=/path/to/projects/home (/var/www or
/Library/WebServer)
PROJECT_NAME=myproject
DB_ENGINE=mysql
DB_NAME=$PROJECT_NAME
DB_USER=
DB_PASS=
# Leave $DB_HOST blank if the server is on the local machine
DB_HOST=

cd $PROJECT_CONTAINER

django-admin.py startproject $PROJECT_NAME

cd $PROJECT_NAME

#Create Database $DB_NAME
mysqladmin create $DB_NAME

#Modify settings.py
mv "settings.py" "settings.old.py"
OLDENGINE="DATABASE_ENGINE = ''"
NEWENGINE="DATABASE_ENGINE = '$DB_ENGINE'"
OLDNAME="DATABASE_NAME = ''"
NEWNAME="DATABASE_NAME = '$DB_NAME'"
OLDPASS="DATABASE_PASSWORD = ''"
NEWPASS="DATABASE_PASSWORD = '$DB_PASS'"
OLDUSER="DATABASE_USER = ''"
NEWUSER="DATABASE_USER = '$DB_USER'"
OLDHOST="DATABASE_HOST = ''"
NEWHOST="DATABASE_HOST = '$DB_HOST'"
sed -e "s/$OLDENGINE/$NEWENGINE/g" "settings.old.py" | \
sed -e "s/$OLDNAME/$NEWNAME/g" | \
sed -e "s/$OLDPASS/$NEWPASS/g" | \
sed -e "s/$OLDUSER/$NEWUSER/g" | \
sed -e "s/$OLDHOST/$NEWHOST/g" > "settings.py"
rm "settings.old.py"

#Add "django.contrib.admin" to the INSTALLED_APPS setting of
settings.py
# Do it manually?

# Modify urls.py Uncomment the line that says "Uncomment for admin"
mv "urls.py" "urls.old.py"
OLD="#     (r"
NEW="     (r"
sed -e "s/$OLD/$NEW/g" "urls.old.py" > "urls.py"
rm "urls.old.py"

#python2.4 manage.py syncdb

#Now create apps using:

#python2.4 manage.py startapp $APP_NAME

#cd $APP_NAME

#edit models.py


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to