diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py index a58cd69543..791d1fb3d1 100644 --- a/django/db/backends/__init__.py +++ b/django/db/backends/__init__.py @@ -499,12 +499,14 @@ class BaseDatabaseIntrospection(object): If only_existing is True, the resulting list will only include the tables that actually exist in the database. """ - from django.db import models + from django.db import models, router tables = set() for app in models.get_apps(): for model in models.get_models(app): if not model._meta.managed: continue + if not router.allow_syncdb(self.connection.alias, model): + continue tables.add(model._meta.db_table) tables.update([f.m2m_db_table() for f in model._meta.local_many_to_many]) if only_existing: @@ -513,18 +515,19 @@ class BaseDatabaseIntrospection(object): def installed_models(self, tables): "Returns a set of all models represented by the provided list of table names." - from django.db import models + from django.db import models, router all_models = [] for app in models.get_apps(): for model in models.get_models(app): - all_models.append(model) + if router.allow_syncdb(self.connection.alias, model): + all_models.append(model) return set([m for m in all_models if self.table_name_converter(m._meta.db_table) in map(self.table_name_converter, tables) ]) def sequence_list(self): "Returns a list of information about all DB sequences for all models in all apps." - from django.db import models + from django.db import models, router apps = models.get_apps() sequence_list = [] @@ -533,6 +536,8 @@ class BaseDatabaseIntrospection(object): for model in models.get_models(app): if not model._meta.managed: continue + if not router.allow_syncdb(self.connection.alias, model): + continue for f in model._meta.local_fields: if isinstance(f, models.AutoField): sequence_list.append({'table': model._meta.db_table, 'column': f.column})