Browse files

Added experimental support for a POSTGIS_VERSION setting for GeoDjang…

…o. If set, it will tell GeoDjango not to do the postgis_lib_version() query every time the server starts up (assuming a PostGIS backend). This is intentionally undocumented because Justin mentioned he might be refactoring the backends for Django 1.2 such that this setting would be unnecessary. Until then, people can use this hook.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 91fe5d5 commit ffd7b177c9eea9cfe131bc20a98448345436d67e @adrianholovaty adrianholovaty committed Apr 12, 2009
Showing with 17 additions and 3 deletions.
  1. +17 −3 django/contrib/gis/db/backend/postgis/
@@ -2,16 +2,30 @@
This module contains the spatial lookup types, and the get_geo_where_clause()
routine for PostGIS.
import re
from decimal import Decimal
from django.db import connection
+from django.conf import settings
from django.contrib.gis.measure import Distance
-from import postgis_version_tuple
from django.contrib.gis.db.backend.util import SpatialOperation, SpatialFunction
qn = connection.ops.quote_name
-# Getting the PostGIS version information
+# Get the PostGIS version information.
+# To avoid the need to do a database query to determine the PostGIS version
+# each time the server starts up, one can optionally specify a
+# POSTGIS_VERSION setting. This setting is intentionally undocumented and
+# should be considered experimental, because an upcoming GIS backend
+# refactoring might remove the need for it.
+if hasattr(settings, 'POSTGIS_VERSION') and settings.POSTGIS_VERSION is not None:
+ version_tuple = settings.POSTGIS_VERSION
+ # This import is intentionally within the 'else' so that it isn't executed
+ # if the POSTGIS_VERSION setting is available.
+ from import postgis_version_tuple
+ version_tuple = postgis_version_tuple()
# The supported PostGIS versions.
# TODO: Confirm tests with PostGIS versions 1.1.x -- should work.

0 comments on commit ffd7b17

Please sign in to comment.