Created
January 6, 2017 22:15
-
-
Save rjdp/b5d377c535cf72c040d0c2c9396f6de1 to your computer and use it in GitHub Desktop.
incase using tenant_schemas 1.5.2 with django1.5.x use this diff to patch to tenant_schemas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/postgresql_backend/introspection.py b/postgresql_backend/introspection.py | |
index a856d26..d030edb 100644 | |
--- a/postgresql_backend/introspection.py | |
+++ b/postgresql_backend/introspection.py | |
@@ -11,4 +11,5 @@ class DatabaseSchemaIntrospection(DatabaseIntrospection): | |
WHERE c.relkind IN ('r', 'v', '') | |
AND n.nspname = '%s' | |
AND pg_catalog.pg_table_is_visible(c.oid)""" % self.connection.schema_name) | |
- return [row[0] for row in cursor.fetchall() if row[0] not in self.ignored_tables] | |
+ #return [row[0] for row in cursor.fetchall() if row[0] not in self.ignored_tables] | |
+ return [row[0] for row in cursor.fetchall()] | |
diff --git a/utils.py b/utils.py | |
index b3f4f80..b5c5e62 100644 | |
--- a/utils.py | |
+++ b/utils.py | |
@@ -1,12 +1,11 @@ | |
from contextlib import contextmanager | |
from django.conf import settings | |
-from django.db import connection | |
-from django.db.models.loading import get_model | |
from django.core import mail | |
@contextmanager | |
def schema_context(schema_name): | |
+ from django.db import connection | |
previous_tenant = connection.tenant | |
try: | |
connection.set_schema(schema_name) | |
@@ -20,6 +19,7 @@ def schema_context(schema_name): | |
@contextmanager | |
def tenant_context(tenant): | |
+ from django.db import connection | |
previous_tenant = connection.tenant | |
try: | |
connection.set_tenant(tenant) | |
@@ -32,6 +32,7 @@ def tenant_context(tenant): | |
def get_tenant_model(): | |
+ from django.db.models.loading import get_model | |
return get_model(*settings.TENANT_MODEL.split(".")) | |
@@ -82,6 +83,7 @@ def django_is_in_test_mode(): | |
def schema_exists(schema_name): | |
+ from django.db import connection | |
cursor = connection.cursor() | |
# check if this schema already exists in the db |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment