diff options
| author | Sylvain Fankhauser <sylvain.fankhauser@liip.ch> | 2015-06-05 12:41:51 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2015-06-05 21:58:30 +0200 |
| commit | 0a899157836cc4c3d3980ab6a70b2f37bbb7ba97 (patch) | |
| tree | a52245951c689e9417380085251e350927c61bc7 | |
| parent | 541f4ea546ad3065852db816769ba6b584e3f373 (diff) | |
Fixed #24862 -- Improved PostGIS database connection error message
Thanks brycenesbitt for the patch.
| -rw-r--r-- | django/contrib/gis/db/backends/postgis/operations.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py index 3c2e36e2ac..3e7aa5cdde 100644 --- a/django/contrib/gis/db/backends/postgis/operations.py +++ b/django/contrib/gis/db/backends/postgis/operations.py @@ -150,11 +150,17 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations): if hasattr(settings, 'POSTGIS_VERSION'): version = settings.POSTGIS_VERSION else: + # Run a basic query to check the status of the connection so we're + # sure we only raise the error below if the problem comes from + # PostGIS and not from PostgreSQL itself (see #24862). + self._get_postgis_func('version') + try: vtup = self.postgis_version_tuple() except ProgrammingError: raise ImproperlyConfigured( - 'Cannot determine PostGIS version for database "%s". ' + 'Cannot determine PostGIS version for database "%s" ' + 'using command "SELECT postgis_lib_version()". ' 'GeoDjango requires at least PostGIS version 2.0. ' 'Was the database created from a spatial database ' 'template?' % self.connection.settings_dict['NAME'] |
