Commit 2732edc5 authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

Deprecated get_apps().

parent d44de9b9
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -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.
@@ -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])

+2 −2
Original line number Diff line number Diff line
@@ -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)

+3 −1
Original line number Diff line number Diff line
@@ -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")
+2 −2
Original line number Diff line number Diff line
@@ -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)
+4 −3
Original line number Diff line number Diff line
@@ -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