Installing GeoDjango and PostGIS with Postgres 9.1 on Ubuntu 11.10
Published: 09 Nov 2011
Django's GIS framework is superb, and really fairly simple to use, but it can be a bit of a pain to get PostGIS and associated bits installed.
The instructions here were a great help, but I needed to update a few things to get them working for Postgres 9.1. I've put everything into a bash script which will do everything for you, here, and there's a few other notes below.
PostGIS compilation errors
Attempting to compile and install PostGIS gave me an error:
cannot create directory `/usr/share/postgresql/9.1/contrib': No such file or directory
I had the postgresql-contrib-9.1 package installed, and couldn't see why we didn't have perms to create this directory, so I created it:
sudo mkdir -p '/usr/share/postgresql/9.1/contrib/postgis-1.5'
Then ran it again, and it all installed fine. It appears that the contrib location has moved.
Django 1.3 and standard_conforming_string
When attempting to use the models with Django 1.3 you may well see:
django.db.utils.DatabaseError: invalid byte sequence for encoding "UTF8": 0x00
This is due an incompatibility between a change in Postgres 9.1's new default config and Django 1.3. It requires the postgres setting for standard_conforming_string to be off, but it's switched on by default now.



