summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/contrib/gis/gdal/__init__.py12
-rw-r--r--django/contrib/gis/models.py5
2 files changed, 10 insertions, 7 deletions
diff --git a/django/contrib/gis/gdal/__init__.py b/django/contrib/gis/gdal/__init__.py
index 22f962c0e5..b318850b28 100644
--- a/django/contrib/gis/gdal/__init__.py
+++ b/django/contrib/gis/gdal/__init__.py
@@ -47,9 +47,13 @@ except:
HAS_GDAL, GEOJSON = False, False
# The envelope, error, and geomtype modules do not actually require the
-# GDAL library.
+# GDAL library, but still nead at least Python 2.4 and ctypes.
PYTHON23 = sys.version_info[0] == 2 and sys.version_info[1] == 3
if not PYTHON23:
- from django.contrib.gis.gdal.envelope import Envelope
- from django.contrib.gis.gdal.error import check_err, OGRException, OGRIndexError, SRSException
- from django.contrib.gis.gdal.geomtype import OGRGeomType
+ try:
+ from django.contrib.gis.gdal.envelope import Envelope
+ from django.contrib.gis.gdal.error import check_err, OGRException, OGRIndexError, SRSException
+ from django.contrib.gis.gdal.geomtype import OGRGeomType
+ except ImportError:
+ # No ctypes, but don't raise an exception.
+ pass
diff --git a/django/contrib/gis/models.py b/django/contrib/gis/models.py
index bb068ec5df..4453dd89fc 100644
--- a/django/contrib/gis/models.py
+++ b/django/contrib/gis/models.py
@@ -214,11 +214,10 @@ if not PYTHON23 and settings.DATABASE_ENGINE == 'postgresql_psycopg2':
# Because the PostGIS version is checked when initializing the spatial
# backend a `ProgrammingError` will be raised if the PostGIS tables
# and functions are not installed. We catch here so it won't be raised when
- # running the Django test suite.
- from psycopg2 import ProgrammingError
+ # running the Django test suite. `ImportError` is also possible if no ctypes.
try:
from django.contrib.gis.db.backend.postgis.models import GeometryColumns, SpatialRefSys
- except ProgrammingError:
+ except:
_srid_info = False
elif not PYTHON23 and settings.DATABASE_ENGINE == 'oracle':
# Same thing as above, except the GEOS library is attempted to be loaded for