attribute: Phillie Casablanca

Geodjango testing on windows with postgres/postgis

While trying to get django's builtin testing system working ( with postgres/postgis and geodjango I hit a roadblock.

Basically, I was hoping it would just work, but my first attempt brought up an exception:

$ python test myapp
Creating new spatial database...
Traceback (most recent call last):
File "", line 11, in <module>
File "C:\Python26\Lib\site-packages\django\core\management\", line 340, in execute_manager
File "C:\Python26\Lib\site-packages\django\core\management\", line 295, in execute
File "C:\Python26\Lib\site-packages\django\core\management\", line 192, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python26\Lib\site-packages\django\core\management\", line 219, in execute
output = self.handle(*args, **options)
File "C:\Python26\Lib\site-packages\django\core\management\commands\", line 33, in handle
failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive)
File "C:\Python26\Lib\site-packages\django\contrib\gis\tests\", line 196, in run_tests
create_spatial_db(test=True, verbosity=verbosity)
File "C:\Python26\Lib\site-packages\django\contrib\gis\db\backend\postgis\", line 118, in create_spatial_d

load_postgis_sql(db_name, verbosity=verbosity)
File "C:\Python26\Lib\site-packages\django\contrib\gis\db\backend\postgis\", line 189, in load_postgis_sql
raise Exception('Could not find PostGIS function definitions in %s' % lwpostgis_file)
Exception: Could not find PostGIS function definitions in C:/PROGRA~1/POSTGR~1/8.3/share\lwpostgis.sql

ugh! Ok, so searching around I found this nice series of posts describing the issue:

I'm running postgres/postgis on windows and so I added the following to my settings file (I'm using Django 1.0.2):

POSTGIS_SQL_PATH = 'C:\\Program Files\\PostgreSQL\\8.3\\share\\contrib'

Runnning tests for myapp again, asked for the postgres db password when trying to run some sql found in the contrib directory, but it now appears to run successfully!

monkut // May 7, 2009 // 8:04 a.m.