Version 3 (modified by jbronn, 8 years ago) (diff)

Updated errors.

These instructions apply for Debian Lenny and GeoDjango on django1.0 and postgresql-8.3

Packages Installation

Debian Lenny is shiped with the needed packages and defaults to python2.5

sudo apt-get install libgeos-3.0.0 proj postgis gdal-bin postgresql-8.3-postgis postgresql-8.3

Create a database template

This database could be used for recreating your geodjango powering databases

$ sudo su - postgres
$ createdb -E UTF8 template_postgis # Create the template spatial database.
$ createlang -d template_postgis plpgsql # Adding PLPGSQL language support.
$ psql -d template_postgis -f /usr/share/postgresql-8.3-postgis/lwpostgis.sql
$ psql -d template_postgis -f /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql
$ psql -d template_postgis # Enabling users to alter spatial tables.
template_postgis=# GRANT ALL ON geometry_columns TO PUBLIC;
template_postgis=# GRANT ALL ON spatial_ref_sys TO PUBLIC;

Testing the configuration

Make sure the new libraries are on the path, eventually logoff and sign in again.

export DJANGO_SETTINGS_MODULE=myproject.settings

The following tests should run flawlessly.

>>> from django.contrib.gis.gdal import HAS_GDAL
>>> print HAS_GDAL # Will be False if GDAL libraries are not found
>>> from django.contrib.gis.tests import test_gdal
>>> from django.contrib.gis.tests import test_geos

Creating a database

Now when creating a new database, use postgis_template as template (substitute in the appropriate database owner and the database name:

sudo su postgres createdb -T postgis_template -O db_user db_name


If you hit errors, please refer to GeoDjangoInstall

Back to Top