from django.db import DEFAULT_DB_ALIAS, connections from django.db.migrations.executor import MigrationExecutor def get_remaining_migrations(): connection = connections[DEFAULT_DB_ALIAS] connection.prepare_database() executor = MigrationExecutor(connection) targets = executor.loader.graph.leaf_nodes() migrations= executor.migration_plan(targets) return migrations