Version 31 (modified by 16 years ago) ( diff ) | ,
---|
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
- Download and unpack latest stable python tarball
./configure --prefix=/opt/python; make; make install
- Add
export PATH=/opt/python/bin:$PATH
andexport MANPATH=/opt/python/man:$MANPATH
to~/.profile
- Open a new terminal session
- Type
python
and check that it is the version you just installed
Installing PostgreSQL
- Create a new user, postgres in the Accounts Pane of the Mac OS X System Preferences
- Download and unpack latest stable PostgreSQL tarball
./configure --prefix=/opt/pgsql; make; sudo make install
- Add
export PATH=/opt/pgsql/bin:$PATH
andexport MANPATH=/opt/pgsql/man:$MANPATH
to~/.profile
- Add
export PGDATA=/opt/pgsql/data
to~/.profile
NOTE: If this isn't set, postgres will complain about a missing conf file. - Open a new terminal session
- Type
psql -V
and check that it is the version you just installed - Create a data directory:
sudo mkdir $PGDATA
- Change ownership to postgres:
sudo chown postgres:postgres $PGDATA
- 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. - To run the database (will not be automatically started on boot):
sudo -u postgres pg_ctl start
- Open a new window, and type
sudo -u postgres createdb test
. If it saysCREATE 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.
- Download the latest stable tartball of mxDateTime
- Unpack the tarball and go into the directory
python setup.py build
sudo python setup.py install
- Download the latest stable tarball of psycopg1, unpack and go into the directory
export MACOSX_DEPLOYMENT_TARGET=10.4
export CPPFLAGS="-I/opt/python/lib/python2.4/site-packages/mx/DateTime/mxDateTime"
./configure --with-postgres-libraries=$(pg_config --libdir) --with-postgres-includes=$(pg_config --includedir)
make
sudo make install
- Run
python
, typeimport psycopg
into the interactive read-eval-print loop (REPL), andquit
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.
- Install postgres81
- Install postgres81-dev
- get the latest and greatest psycopg2 (I'm using psycopg2-2.0.5 but please read ticket:3364)
- keep to the rest of this tutorial but use psycopg2 instead of psypg1
- Note: install psycopg2 ist just
python setup.py build
andpython setup.py install
psycopg1 wouldn't install with fink...
- Note: install psycopg2 ist just
' 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
- sudo port install py-egenix-mx-base
- 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