Loading django/apps/cache.py +9 −6 Original line number Diff line number Diff line Loading @@ -189,12 +189,6 @@ class BaseAppCache(object): raise UnavailableApp("App with label %r isn't available." % app_label) return app_config def get_apps(self): """ Returns a list of all installed modules that contain models. """ return [app_config.models_module for app_config in self.get_app_configs()] def get_app(self, app_label): """ Returns the module containing the models for the given app_label. Loading Loading @@ -338,6 +332,15 @@ class BaseAppCache(object): ### DEPRECATED METHODS GO BELOW THIS LINE ### def get_apps(self): """ Returns a list of all installed modules that contain models. """ warnings.warn( "[a.models_module for a in get_app_configs()] supersedes get_apps().", PendingDeprecationWarning, stacklevel=2) return [app_config.models_module for app_config in self.get_app_configs()] def _get_app_package(self, app): return '.'.join(app.__name__.split('.')[:-1]) Loading django/contrib/contenttypes/management.py +2 −2 Original line number Diff line number Diff line Loading @@ -86,8 +86,8 @@ If you're unsure, answer 'no'. def update_all_contenttypes(verbosity=2, **kwargs): for app in app_cache.get_apps(): update_contenttypes(app, None, verbosity, **kwargs) for app_config in app_cache.get_app_configs(): update_contenttypes(app_config.models_module, None, verbosity, **kwargs) signals.post_migrate.connect(update_contenttypes) Loading django/core/management/commands/dumpdata.py +3 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,9 @@ class Command(BaseCommand): if len(app_labels) == 0: if primary_keys: raise CommandError("You can only use --pks option with one model") app_list = OrderedDict((app, None) for app in app_cache.get_apps() if app not in excluded_apps) app_list = OrderedDict((app_config.models_module, None) for app_config in app_cache.get_app_configs() if app_config.models_module not in excluded_apps) else: if len(app_labels) > 1 and primary_keys: raise CommandError("You can only use --pks option with one model") Loading django/core/management/commands/flush.py +2 −2 Original line number Diff line number Diff line Loading @@ -94,6 +94,6 @@ Are you sure you want to do this? # Emit the post migrate signal. This allows individual applications to # respond as if the database had been migrated from scratch. all_models = [] for app in app_cache.get_apps(): all_models.extend(router.get_migratable_models(app, database, include_auto_created=True)) for app_config in app_cache.get_app_configs(): all_models.extend(router.get_migratable_models(app_config.models_module, database, include_auto_created=True)) emit_post_migrate_signal(set(all_models), verbosity, interactive, database) django/core/management/commands/migrate.py +4 −3 Original line number Diff line number Diff line Loading @@ -180,9 +180,10 @@ class Command(BaseCommand): # Build the manifest of apps and models that are to be synchronized all_models = [ (app.__name__.split('.')[-2], router.get_migratable_models(app, connection.alias, include_auto_created=True)) for app in app_cache.get_apps() if app.__name__.split('.')[-2] in apps (app_config.label, router.get_migratable_models(app_config.models_module, connection.alias, include_auto_created=True)) for app_config in app_cache.get_app_configs() if app_config.label in apps ] def model_installed(model): Loading Loading
django/apps/cache.py +9 −6 Original line number Diff line number Diff line Loading @@ -189,12 +189,6 @@ class BaseAppCache(object): raise UnavailableApp("App with label %r isn't available." % app_label) return app_config def get_apps(self): """ Returns a list of all installed modules that contain models. """ return [app_config.models_module for app_config in self.get_app_configs()] def get_app(self, app_label): """ Returns the module containing the models for the given app_label. Loading Loading @@ -338,6 +332,15 @@ class BaseAppCache(object): ### DEPRECATED METHODS GO BELOW THIS LINE ### def get_apps(self): """ Returns a list of all installed modules that contain models. """ warnings.warn( "[a.models_module for a in get_app_configs()] supersedes get_apps().", PendingDeprecationWarning, stacklevel=2) return [app_config.models_module for app_config in self.get_app_configs()] def _get_app_package(self, app): return '.'.join(app.__name__.split('.')[:-1]) Loading
django/contrib/contenttypes/management.py +2 −2 Original line number Diff line number Diff line Loading @@ -86,8 +86,8 @@ If you're unsure, answer 'no'. def update_all_contenttypes(verbosity=2, **kwargs): for app in app_cache.get_apps(): update_contenttypes(app, None, verbosity, **kwargs) for app_config in app_cache.get_app_configs(): update_contenttypes(app_config.models_module, None, verbosity, **kwargs) signals.post_migrate.connect(update_contenttypes) Loading
django/core/management/commands/dumpdata.py +3 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,9 @@ class Command(BaseCommand): if len(app_labels) == 0: if primary_keys: raise CommandError("You can only use --pks option with one model") app_list = OrderedDict((app, None) for app in app_cache.get_apps() if app not in excluded_apps) app_list = OrderedDict((app_config.models_module, None) for app_config in app_cache.get_app_configs() if app_config.models_module not in excluded_apps) else: if len(app_labels) > 1 and primary_keys: raise CommandError("You can only use --pks option with one model") Loading
django/core/management/commands/flush.py +2 −2 Original line number Diff line number Diff line Loading @@ -94,6 +94,6 @@ Are you sure you want to do this? # Emit the post migrate signal. This allows individual applications to # respond as if the database had been migrated from scratch. all_models = [] for app in app_cache.get_apps(): all_models.extend(router.get_migratable_models(app, database, include_auto_created=True)) for app_config in app_cache.get_app_configs(): all_models.extend(router.get_migratable_models(app_config.models_module, database, include_auto_created=True)) emit_post_migrate_signal(set(all_models), verbosity, interactive, database)
django/core/management/commands/migrate.py +4 −3 Original line number Diff line number Diff line Loading @@ -180,9 +180,10 @@ class Command(BaseCommand): # Build the manifest of apps and models that are to be synchronized all_models = [ (app.__name__.split('.')[-2], router.get_migratable_models(app, connection.alias, include_auto_created=True)) for app in app_cache.get_apps() if app.__name__.split('.')[-2] in apps (app_config.label, router.get_migratable_models(app_config.models_module, connection.alias, include_auto_created=True)) for app_config in app_cache.get_app_configs() if app_config.label in apps ] def model_installed(model): Loading