Skip to content

Instantly share code, notes, and snippets.

@erickgnavar
Forked from fcurella/django_postgis_on_os_x.md
Created November 10, 2013 02:59
Show Gist options
  • Save erickgnavar/7393144 to your computer and use it in GitHub Desktop.
Save erickgnavar/7393144 to your computer and use it in GitHub Desktop.

Django and Postgis on OS X

Install Homebrew

Install a few things with homebrew:

Notice that some packages give you information at the end, read it carefully. To recall that info use brew info like this: $ brew info postgresql

$ brew install python --universal

Note: if you plan on running graphical apps with this python installation add --framework as well.

Some geo dependencies:

Django doesn't currently work with Postgis 2.x, so we have to install 1.5.x (see ticket #16455). Also, PostGis 1.5 does not work with Postgres 9.2, so we are going to install v9.0.8

$ brew tap homebrew/versions
$ brew install postgis15
$ brew install postgresql9
$ brew untap homebrew/versions
$ brew install gdal geos

Create the template_postgis template database

$ createdb template_postgis
$ psql -f /usr/local/share/postgis/postgis.sql template_postgis
$ psql -f /usr/local/share/postgis/spatial_ref_sys.sql template_postgis

Create a new db:

$ createdb -T template_postgis mydatabase

Dump/Restore:

$ pg_dump -Fc mydatabase > /tmp/mydatabase.db
$ postgis_restore.pl /usr/local/Cellar/postgis/1.5.3/share/postgis/postgis.sql mydatabase /tmp/mydatabase.db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment