Skip to content

Commit

Permalink
Merge pull request #282 from regolith/master
Browse files Browse the repository at this point in the history
Update allow_migrate() for Django 1.8. Fixes #231 (in 1.8)
  • Loading branch information
bernardopires committed Sep 4, 2015
2 parents b9cf3cb + d19de3c commit 85ef2f4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tenant_schemas/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ class TenantSyncRouter(object):
depending if we are syncing the shared apps or the tenant apps.
"""

def allow_migrate(self, db, model):
def allow_migrate(self, db, app_label, model_name=None, **hints):
# the imports below need to be done here else django <1.5 goes crazy
# https://code.djangoproject.com/ticket/20704
from django.db import connection
from tenant_schemas.utils import get_public_schema_name, app_labels

if not isinstance(app_label, str):
# In django 1.7 the `app_label` parameter is actually `model`
app_label = app_label._meta.app_label

if connection.schema_name == get_public_schema_name():
if model._meta.app_label not in app_labels(settings.SHARED_APPS):
if app_label not in app_labels(settings.SHARED_APPS):
return False
else:
if model._meta.app_label not in app_labels(settings.TENANT_APPS):
if app_label not in app_labels(settings.TENANT_APPS):
return False

return None
Expand Down

0 comments on commit 85ef2f4

Please sign in to comment.