from django.conf import settings


class TenantSyncRouter(object):
    """
    A router to control which applications will be synced,
    depending if we are syncing the shared apps or the tenant apps.
    """

    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 django_tenants.utils import get_public_schema_name, app_labels

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

        return None

@@ -513,20 +513,145 @@
 name
-, app_labels
+%0A%0A        # for INSTALLED_APPS we need a name%0A        from django.apps import apps%0A        app_name = apps.get_app_config(app_label).name
 %0A%0A  
@@ -726,37 +726,36 @@
      if app_
-label
+name
  not in 
 app_labels(s
@@ -738,35 +738,24 @@
 name not in 
-app_labels(
 settings.SHA
@@ -758,25 +758,24 @@
 .SHARED_APPS
-)
 :%0A          
@@ -830,21 +830,20 @@
 app_
-label
+name
  not in 
 app_
@@ -842,19 +842,8 @@
  in 
-app_labels(
 sett
@@ -858,17 +858,16 @@
 ANT_APPS
-)
 :%0A      

fix for django 1.8