Development (Mac OS X Tiger)

Originally written by Ben Atkin

These instructions are for Django 0.91. I hope to update this with most new releases.

I prefer the latest tarballs for general development. If I ever start to get really into the software I get the CVS or SVN.

Before beginning, install XCode. XCode contains make, gcc, and other things you'll be needing when compiling from source.

As an alternative to these instructions, consider installing DarwinPorts. It simplifies installing up-to-date versions of apache2, python 2.4, mod_python, PIL, and the various databases that Django supports. A write up walking through the packages to install with DarwinPorts to get a quick install running is available at http://www.rhonabwy.com/wp/2006/07/20/installing-django-on-macos-x-development-version/

Installing Python

  1. Download and unpack latest stable python tarball
  2. ./configure --prefix=/opt/python; make; make install
  3. Add export PATH=/opt/python/bin:$PATH and export MANPATH=/opt/python/man:$MANPATH to ~/.profile
  4. Open a new terminal session
  5. Type python and check that it is the version you just installed

Installing PostgreSQL

  1. Create a new user, postgres in the Accounts Pane of the Mac OS X System Preferences
  2. Download and unpack latest stable PostgreSQL tarball
  3. ./configure --prefix=/opt/pgsql; make; sudo make install
  4. Add export PATH=/opt/pgsql/bin:$PATH and export MANPATH=/opt/pgsql/man:$MANPATH to ~/.profile
  5. Add export PGDATA=/opt/pgsql/data to ~/.profile NOTE: If this isn't set, postgres will complain about a missing conf file.
  6. Open a new terminal session
  7. Type psql -V and check that it is the version you just installed
  8. Create a data directory: sudo mkdir $PGDATA
  9. Change ownership to postgres: sudo chown postgres:postgres $PGDATA
  10. Create the initial data area: sudo -u postgres initdb -D $PGDATA NOTE: sudo means substitute user and do, and in this case with the initial -u parameter, we are telling sudo to run the command as postgres rather than root.
  11. To run the database (will not be automatically started on boot): sudo -u postgres pg_ctl start
  12. Open a new window, and type sudo -u postgres createdb test. If it says CREATE DATABASE, it's working. :)

Installing psycopg (PostgreSQL Bindings)

At the time of this writing, the only stable version of psycopg is psycopg1. The development version psycopg2 is not supported by Django.

  1. Download the latest stable tartball of mxDateTime
  2. Unpack the tarball and go into the directory
  3. python setup.py build
  4. sudo python setup.py install
  5. Download the latest stable tarball of psycopg1, unpack and go into the directory
  6. export MACOSX_DEPLOYMENT_TARGET=10.4
  7. export CPPFLAGS="-I/opt/python/lib/python2.4/site-packages/mx/DateTime/mxDateTime"
  8. ./configure --with-postgres-libraries=$(pg_config --libdir) --with-postgres-includes=$(pg_config --includedir)
  9. make
  10. sudo make install
  11. Run python, type import psycopg into the interactive read-eval-print loop (REPL), and quit the REPL.

I had some issues with the above instructions for installing psycopg, and had to refer directly to the untarred installation source for mxDateTime in order to get the headers. To do this change the configure command to:

./configure --with-postgres-libraries=$(pg_config --libdir) --with-postgres-includes=$(pg_config --includedir) --with-mxdatetime-includes=[path/to/mxdatetime]/egenix-mx-base-2.0.6/mx/DateTime/mxDateTime

the CPPFLAGS line that worked for me was:

export CPPFLAGS="-I/Library/Python/2.3/site-packages/mx/DateTime/mxDateTime"

The Fink Way

I'm referring to ticket:3364 it was the reason why I couldn't get it to work.

  1. Install postgres81
  2. Install postgres81-dev
  3. get the latest and greatest psycopg2 (I'm using psycopg2-2.0.5 but please read ticket:3364)
  4. keep to the rest of this tutorial but use psycopg2 instead of psypg1
    • Note: install psycopg2 ist just python setup.py buildand python setup.py install psycopg1 wouldn't install with fink...

' In settings.py in your django project use the backend postgresql_psycopg2 otherwise you'll get a bunch of errors about not finding the psycopg package which we aren't using anyway because we now use psycopg2.

Darwin Ports way

Alternative method for installing psycopg is using the darwin ports

  1. sudo port install py-egenix-mx-base
  2. sudo port install py-psycopg

Darwin ports are available at http://darwinports.opendarwin.org/

Installation Django 1.0 (Mac OS X Leopard 10.5)

Written by Bess Ho 09.08.08, amended by zgoda 05.11.08

OSX 10.5 includes Python 2.5 that support Django 1.0. If you want to use MacPorts version of Python, you must install additional packages if you want to use SQLite as your database (py25-sqlite3 and py25-hashlib).

Get the latest official version

First, download Django-1.0.tar.gz. Then:

tar xzvf Django-1.0.tar.gz

cd Django-1.0

sudo python setup.py install

View SQLite3 Database

cd into the directory where your Django 1.0 project is created. Run sqlite3 and select the database name sample.db. Use .schema to view the database statements.

$ sqlite3 sample.db

$ .schema

Using Postgres Databases in Django 1.0 and Mac OSX Leopard

Writen by sedibr

After install Django, install the bundle Postgres Plus, from http://www.enterprisedb.com/products/postgres_plus/download.do. The package provides Postgress Core installation plus a couple of very usefull GUI tools.

As mentioned before, you should set some ENVIRONMENT variables. This is an example for PostgresPlus 8.3 package: Add export PATH=/Library/PostgresPlus/8.3/bin:$PATH and export MANPATH=/Library/PostgresPlus/8.3/man:$MANPATH to ~/.profile Add export PGDATA=/Library/PostgresPlus/8.3/data to ~/.profile

Download and build psycopg as stated above. In your settings.py file choose postgresql_psycopg2 adapter to your database.

Last modified 15 years ago Last modified on Jul 19, 2009, 12:15:43 PM
Note: See TracWiki for help on using the wiki.
Back to Top