Install Django on OS-X Snow Leopard using sqlite3

Download django.   It should default to your ~/Downloads folder and it should be untarred. Go into that directory (in my case, /Users/gregcain/Downloads/Django-1.2.4), and install Django.

sudo python install

Now we need to configure our first project, which we’ll call myBooks. Create the parent directory you want your project to live in.

mkdir ~/Django

Let’s create the first project startproject myBooks

You’ll see a directory created underneath your Django directory called myBooks. (~/Django/myBooks) In that directory, you’ll see the following files…

Start the built in web server. From the directory ~/Django/myBooks directory

python runserver

Which gives you this..

Django version 1.2.4, using settings 'myBooks.settings'
Development server is running at
Quit the server with CONTROL-C.

If you point your web browser to you should see this basic getting started page

If you see that, all is good so far…

Now let’s configure Django to use sqlite as it’s database. All you need to do is edit the file in ~/Django/myBooks. You need to change ENGINE to the sqlite3 instance, and tell it where you want your database to live. You’ll create that database in the next step.

    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': '/Users/gregcain/Django/myBooks/myBooksDB',                      # Or path to database file if using sqlite3.
        'USER': '',                      # 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.

Now create the database

python syncdb

You’ll be asked a few questions, including one to setup a super user.

Now that the database is created, let’s go in and see if it looks correct. To open a connection to the database

sqlite3 myBooksDB

and to see the schema


Happy Coding!!