Permalink
Browse files

Don't initialize PostGIS-specific stuff for non-db connections

Refs #16969.
  • Loading branch information...
1 parent 3c10d1e commit 7e714827ead50f77aa82394cc2511ff96ab67fa4 @claudep claudep committed Nov 9, 2013
Showing with 7 additions and 4 deletions.
  1. +5 −3 django/contrib/gis/db/backends/postgis/base.py
  2. +2 −1 django/db/backends/creation.py
View
8 django/contrib/gis/db/backends/postgis/base.py
@@ -1,3 +1,4 @@
+from django.db.backends.creation import NO_DB_ALIAS
from django.db.backends.postgresql_psycopg2.base import DatabaseWrapper as Psycopg2DatabaseWrapper
from django.contrib.gis.db.backends.postgis.creation import PostGISCreation
from django.contrib.gis.db.backends.postgis.introspection import PostGISIntrospection
@@ -7,6 +8,7 @@
class DatabaseWrapper(Psycopg2DatabaseWrapper):
def __init__(self, *args, **kwargs):
super(DatabaseWrapper, self).__init__(*args, **kwargs)
- self.creation = PostGISCreation(self)
- self.ops = PostGISOperations(self)
- self.introspection = PostGISIntrospection(self)
+ if kwargs.get('alias', '') != NO_DB_ALIAS:
+ self.creation = PostGISCreation(self)
+ self.ops = PostGISOperations(self)
+ self.introspection = PostGISIntrospection(self)
View
3 django/db/backends/creation.py
@@ -14,6 +14,7 @@
# The prefix to put on the default database name when creating
# the test database.
TEST_DATABASE_PREFIX = 'test_'
+NO_DB_ALIAS = '__no_db__'
class BaseDatabaseCreation(object):
@@ -44,7 +45,7 @@ def _nodb_connection(self):
backend = load_backend(settings_dict['ENGINE'])
nodb_connection = backend.DatabaseWrapper(
settings_dict,
- alias='__no_db__',
+ alias=NO_DB_ALIAS,
allow_thread_sharing=False)
return nodb_connection

0 comments on commit 7e71482

Please sign in to comment.